/*
 * EditSettings.java
 *
 * Created on August 8, 2007, 8:58 AM
 *
 * @author  pquiring
 *
 */

import java.io.*;
import java.awt.*;
import javax.swing.*;

import javaforce.*;
import javaforce.voip.*;
import javaforce.media.*;

import java.awt.event.KeyEvent;
import javax.swing.filechooser.FileNameExtensionFilter;

/** Dialog to allow user to edit settings. */

public class EditSettings extends javax.swing.JDialog {

  private boolean useH263 = false;  //Disable for now until RTPH263 is complete

  /** Creates new form EditSettings */
  private EditSettings(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    initComponents();
    JFAWT.assignHotKey(this, bCancel, KeyEvent.VK_ESCAPE);
    JFAWT.assignHotKey(this, bSave, KeyEvent.VK_ENTER);
    setPosition();
    byte data[] = null;
    try {
      InputStream is = getClass().getClassLoader().getResourceAsStream("readme.txt");
      int len = is.available();
      data = new byte[len];
      is.read(data);
    } catch (Exception e) {
      JFLog.log("err:load readme.txt Failed:" + e);
      System.exit(0);
    }
    about.setText(new String(data));
    about.setCaretPosition(0);
    setComponentOrientation(((parent == null) ? javax.swing.JOptionPane.getRootFrame() : parent).getComponentOrientation());
    if (parent != null) setLocationRelativeTo(parent);
    disabled_audio_codecs.setModel(disabledAudioCodecsList);
    enabled_audio_codecs.setModel(enabledAudioCodecsList);
    disabled_video_codecs.setModel(disabledVideoCodecsList);
    enabled_video_codecs.setModel(enabledVideoCodecsList);
    loadSettings();
    if (!Settings.isLinux && !Settings.isWindows) {
      useNativeVideo.setEnabled(false);
    }
    updateKeyStatus();
  }

  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    soundGroup = new javax.swing.ButtonGroup();
    videoGroup = new javax.swing.ButtonGroup();
    natGroup = new javax.swing.ButtonGroup();
    bSave = new javax.swing.JButton();
    bCancel = new javax.swing.JButton();
    tabs = new javax.swing.JTabbedPane();
    general = new javax.swing.JPanel();
    jPanel10 = new javax.swing.JPanel();
    jLabel35 = new javax.swing.JLabel();
    speakerThreshold = new javax.swing.JTextField();
    jLabel36 = new javax.swing.JLabel();
    speakerDelay = new javax.swing.JTextField();
    jPanel11 = new javax.swing.JPanel();
    checkVersion = new javax.swing.JCheckBox();
    disableLogging = new javax.swing.JCheckBox();
    hideWhenMinimized = new javax.swing.JCheckBox();
    alwaysOnTop = new javax.swing.JCheckBox();
    smallerFont = new javax.swing.JCheckBox();
    usePublish = new javax.swing.JCheckBox();
    autohold = new javax.swing.JCheckBox();
    jLabel51 = new javax.swing.JLabel();
    sipExpires = new javax.swing.JTextField();
    exitWhenClosed = new javax.swing.JCheckBox();
    reinvite = new javax.swing.JCheckBox();
    jPanel1 = new javax.swing.JPanel();
    jLabel21 = new javax.swing.JLabel();
    dndCodeOn = new javax.swing.JTextField();
    jLabel22 = new javax.swing.JLabel();
    dndCodeOff = new javax.swing.JTextField();
    jPanel2 = new javax.swing.JPanel();
    selectOutRingtone = new javax.swing.JButton();
    jLabel34 = new javax.swing.JLabel();
    inRingtone = new javax.swing.JComboBox();
    outRingtone = new javax.swing.JComboBox();
    jLabel65 = new javax.swing.JLabel();
    selectInRingtone = new javax.swing.JButton();
    audio = new javax.swing.JPanel();
    jPanel13 = new javax.swing.JPanel();
    jLabel20 = new javax.swing.JLabel();
    audioInput = new javax.swing.JComboBox();
    audioOutput = new javax.swing.JComboBox();
    jLabel19 = new javax.swing.JLabel();
    jPanel15 = new javax.swing.JPanel();
    jScrollPane2 = new javax.swing.JScrollPane();
    disabled_audio_codecs = new javax.swing.JList();
    move_audio_codec_up = new javax.swing.JButton();
    move_audio_codec_down = new javax.swing.JButton();
    jScrollPane3 = new javax.swing.JScrollPane();
    enabled_audio_codecs = new javax.swing.JList();
    jLabel41 = new javax.swing.JLabel();
    jLabel42 = new javax.swing.JLabel();
    add_audio_codec = new javax.swing.JButton();
    remove_audio_codec = new javax.swing.JButton();
    jPanel17 = new javax.swing.JPanel();
    jLabel30 = new javax.swing.JLabel();
    downloadPath = new javax.swing.JTextField();
    selectDownloadPath = new javax.swing.JButton();
    keepAudioOpen = new javax.swing.JCheckBox();
    video = new javax.swing.JPanel();
    jPanel14 = new javax.swing.JPanel();
    useNativeVideo = new javax.swing.JRadioButton();
    disableVideo = new javax.swing.JRadioButton();
    jLabel33 = new javax.swing.JLabel();
    videoDevice = new javax.swing.JComboBox();
    videoFPS = new javax.swing.JSlider();
    jLabel32 = new javax.swing.JLabel();
    jPanel18 = new javax.swing.JPanel();
    jScrollPane4 = new javax.swing.JScrollPane();
    disabled_video_codecs = new javax.swing.JList();
    move_video_codec_up = new javax.swing.JButton();
    move_video_codec_down = new javax.swing.JButton();
    jScrollPane5 = new javax.swing.JScrollPane();
    enabled_video_codecs = new javax.swing.JList();
    jLabel46 = new javax.swing.JLabel();
    jLabel47 = new javax.swing.JLabel();
    add_video_codec = new javax.swing.JButton();
    remove_video_codec = new javax.swing.JButton();
    accts = new javax.swing.JPanel();
    jTabbedPane1 = new javax.swing.JTabbedPane();
    l1 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    l1user = new javax.swing.JTextField();
    l1host = new javax.swing.JTextField();
    jLabel23 = new javax.swing.JLabel();
    l1auth = new javax.swing.JTextField();
    l1pass = new javax.swing.JPasswordField();
    l1disableVideo = new javax.swing.JCheckBox();
    l1secure = new javax.swing.JCheckBox();
    jLabel29 = new javax.swing.JLabel();
    l1sip = new javax.swing.JComboBox();
    jLabel56 = new javax.swing.JLabel();
    l1key = new javax.swing.JComboBox();
    jLabel31 = new javax.swing.JLabel();
    l1name = new javax.swing.JTextField();
    l1siplog = new javax.swing.JCheckBox();
    l2 = new javax.swing.JPanel();
    jLabel4 = new javax.swing.JLabel();
    l2user = new javax.swing.JTextField();
    jLabel5 = new javax.swing.JLabel();
    jLabel6 = new javax.swing.JLabel();
    l2host = new javax.swing.JTextField();
    l2same = new javax.swing.JCheckBox();
    l2sameidx = new javax.swing.JComboBox();
    jLabel24 = new javax.swing.JLabel();
    l2auth = new javax.swing.JTextField();
    l2pass = new javax.swing.JPasswordField();
    l2disableVideo = new javax.swing.JCheckBox();
    l2secure = new javax.swing.JCheckBox();
    jLabel37 = new javax.swing.JLabel();
    l2sip = new javax.swing.JComboBox();
    jLabel57 = new javax.swing.JLabel();
    l2key = new javax.swing.JComboBox();
    jLabel44 = new javax.swing.JLabel();
    l2name = new javax.swing.JTextField();
    l2siplog = new javax.swing.JCheckBox();
    l3 = new javax.swing.JPanel();
    l3same = new javax.swing.JCheckBox();
    l3sameidx = new javax.swing.JComboBox();
    l3user = new javax.swing.JTextField();
    jLabel7 = new javax.swing.JLabel();
    jLabel8 = new javax.swing.JLabel();
    l3host = new javax.swing.JTextField();
    jLabel9 = new javax.swing.JLabel();
    jLabel25 = new javax.swing.JLabel();
    l3auth = new javax.swing.JTextField();
    l3pass = new javax.swing.JPasswordField();
    l3disableVideo = new javax.swing.JCheckBox();
    l3secure = new javax.swing.JCheckBox();
    jLabel52 = new javax.swing.JLabel();
    l3sip = new javax.swing.JComboBox();
    jLabel58 = new javax.swing.JLabel();
    l3key = new javax.swing.JComboBox();
    jLabel45 = new javax.swing.JLabel();
    l3name = new javax.swing.JTextField();
    l3siplog = new javax.swing.JCheckBox();
    l4 = new javax.swing.JPanel();
    l4same = new javax.swing.JCheckBox();
    l4sameidx = new javax.swing.JComboBox();
    jLabel10 = new javax.swing.JLabel();
    l4user = new javax.swing.JTextField();
    jLabel11 = new javax.swing.JLabel();
    l4host = new javax.swing.JTextField();
    jLabel12 = new javax.swing.JLabel();
    jLabel26 = new javax.swing.JLabel();
    l4auth = new javax.swing.JTextField();
    l4pass = new javax.swing.JPasswordField();
    l4disableVideo = new javax.swing.JCheckBox();
    l4secure = new javax.swing.JCheckBox();
    jLabel53 = new javax.swing.JLabel();
    l4sip = new javax.swing.JComboBox();
    jLabel59 = new javax.swing.JLabel();
    l4key = new javax.swing.JComboBox();
    jLabel66 = new javax.swing.JLabel();
    l4name = new javax.swing.JTextField();
    l4siplog = new javax.swing.JCheckBox();
    l5 = new javax.swing.JPanel();
    l5same = new javax.swing.JCheckBox();
    l5sameidx = new javax.swing.JComboBox();
    jLabel13 = new javax.swing.JLabel();
    l5user = new javax.swing.JTextField();
    jLabel14 = new javax.swing.JLabel();
    l5host = new javax.swing.JTextField();
    jLabel15 = new javax.swing.JLabel();
    jLabel27 = new javax.swing.JLabel();
    l5auth = new javax.swing.JTextField();
    l5pass = new javax.swing.JPasswordField();
    l5disableVideo = new javax.swing.JCheckBox();
    l5secure = new javax.swing.JCheckBox();
    jLabel54 = new javax.swing.JLabel();
    l5sip = new javax.swing.JComboBox();
    jLabel60 = new javax.swing.JLabel();
    l5key = new javax.swing.JComboBox();
    jLabel67 = new javax.swing.JLabel();
    l5name = new javax.swing.JTextField();
    l5siplog = new javax.swing.JCheckBox();
    l6 = new javax.swing.JPanel();
    l6same = new javax.swing.JCheckBox();
    l6sameidx = new javax.swing.JComboBox();
    jLabel16 = new javax.swing.JLabel();
    l6user = new javax.swing.JTextField();
    jLabel17 = new javax.swing.JLabel();
    l6host = new javax.swing.JTextField();
    jLabel18 = new javax.swing.JLabel();
    jLabel28 = new javax.swing.JLabel();
    l6auth = new javax.swing.JTextField();
    l6pass = new javax.swing.JPasswordField();
    l6disableVideo = new javax.swing.JCheckBox();
    l6secure = new javax.swing.JCheckBox();
    jLabel55 = new javax.swing.JLabel();
    l6sip = new javax.swing.JComboBox();
    jLabel61 = new javax.swing.JLabel();
    l6key = new javax.swing.JComboBox();
    jLabel68 = new javax.swing.JLabel();
    l6name = new javax.swing.JTextField();
    l6siplog = new javax.swing.JCheckBox();
    topology = new javax.swing.JPanel();
    jPanel21 = new javax.swing.JPanel();
    natNone = new javax.swing.JRadioButton();
    natStun = new javax.swing.JRadioButton();
    natTurn = new javax.swing.JRadioButton();
    natIce = new javax.swing.JRadioButton();
    natPrivate = new javax.swing.JCheckBox();
    jLabel39 = new javax.swing.JLabel();
    natHost = new javax.swing.JTextField();
    jLabel49 = new javax.swing.JLabel();
    natUser = new javax.swing.JTextField();
    jLabel50 = new javax.swing.JLabel();
    natPass = new javax.swing.JPasswordField();
    rport = new javax.swing.JCheckBox();
    received = new javax.swing.JCheckBox();
    jPanel22 = new javax.swing.JPanel();
    sipRange = new javax.swing.JCheckBox();
    sipmin = new javax.swing.JTextField();
    jLabel43 = new javax.swing.JLabel();
    sipmax = new javax.swing.JTextField();
    rtpRange = new javax.swing.JCheckBox();
    rtpmin = new javax.swing.JTextField();
    jLabel48 = new javax.swing.JLabel();
    rtpmax = new javax.swing.JTextField();
    eKey = new javax.swing.JPanel();
    jLabel62 = new javax.swing.JLabel();
    jLabel63 = new javax.swing.JLabel();
    keyStatus = new javax.swing.JLabel();
    genCertKey = new javax.swing.JButton();
    jLabel64 = new javax.swing.JLabel();
    dname = new javax.swing.JTextField();
    aboutTab = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    about = new javax.swing.JTextArea();
    help = new javax.swing.JButton();
    jButton1 = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("Edit Settings");
    setModal(true);

    bSave.setText("Save");
    bSave.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        bSaveActionPerformed(evt);
      }
    });

    bCancel.setText("Cancel");
    bCancel.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        bCancelActionPerformed(evt);
      }
    });

    jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder("Speaker Phone Settings"));

    jLabel35.setText("Threshold:");
    jLabel35.setToolTipText("Range: 0-32768 (default = 1000)");

    speakerThreshold.setText("1000");
    speakerThreshold.setToolTipText("Range: 0-32768 (default = 1000)");

    jLabel36.setText("Delay (ms):");
    jLabel36.setToolTipText("default = 250");

    speakerDelay.setText("250");
    speakerDelay.setToolTipText("default = 250");

    javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
    jPanel10.setLayout(jPanel10Layout);
    jPanel10Layout.setHorizontalGroup(
      jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel10Layout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jLabel35)
        .addGap(8, 8, 8)
        .addComponent(speakerThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(jLabel36)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(speakerDelay, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    jPanel10Layout.setVerticalGroup(
      jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel10Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel35)
          .addComponent(speakerThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addComponent(jLabel36)
          .addComponent(speakerDelay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder("Options"));

    checkVersion.setText("Check for update on startup");

    disableLogging.setText("Disable Logging");

    hideWhenMinimized.setText("Hide when minimized");

    alwaysOnTop.setText("Always on top");

    smallerFont.setText("Use Smaller Font");

    usePublish.setText("Enable PUBLISH Presence");
    usePublish.setToolTipText("Not supported by some PBX systems.");

    autohold.setText("Auto Hold/Unhold");
    autohold.setToolTipText("Auto Hold/Unhold while switching between active lines.");

    jLabel51.setText("SIP Expires");
    jLabel51.setToolTipText("Register account every x seconds (Default=3600)");

    sipExpires.setText("3600");

    exitWhenClosed.setText("Exit when closed");

    reinvite.setText("Enable reinvites");
    reinvite.setToolTipText("Reinvites when callee returns multiple codecs.");

    javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
    jPanel11.setLayout(jPanel11Layout);
    jPanel11Layout.setHorizontalGroup(
      jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel11Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
            .addGroup(jPanel11Layout.createSequentialGroup()
              .addComponent(jLabel51)
              .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
              .addComponent(sipExpires))
            .addComponent(hideWhenMinimized)
            .addComponent(disableLogging)
            .addComponent(checkVersion))
          .addComponent(exitWhenClosed))
        .addGap(18, 18, 18)
        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(alwaysOnTop)
          .addComponent(usePublish)
          .addComponent(smallerFont)
          .addComponent(autohold)
          .addComponent(reinvite))
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    jPanel11Layout.setVerticalGroup(
      jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel11Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(jPanel11Layout.createSequentialGroup()
            .addComponent(checkVersion)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(disableLogging)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(hideWhenMinimized)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(exitWhenClosed))
          .addGroup(jPanel11Layout.createSequentialGroup()
            .addComponent(usePublish)
            .addGap(1, 1, 1)
            .addComponent(smallerFont)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(alwaysOnTop)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(autohold)))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel51)
          .addComponent(sipExpires, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addComponent(reinvite))
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Do Not Disturb"));

    jLabel21.setText("Enable:");

    dndCodeOn.setText("*78");
    dndCodeOn.setToolTipText("Do not disturb on code");

    jLabel22.setText("Disable:");

    dndCodeOff.setText("*79");
    dndCodeOff.setToolTipText("Do not disturb off code");

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
      jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel1Layout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jLabel21)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addComponent(dndCodeOn, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(jLabel22)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(dndCodeOff, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    jPanel1Layout.setVerticalGroup(
      jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel21)
          .addComponent(dndCodeOn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addComponent(jLabel22)
          .addComponent(dndCodeOff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addContainerGap())
    );

    jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Tones"));

    selectOutRingtone.setText("Select...");
    selectOutRingtone.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        selectOutRingtoneActionPerformed(evt);
      }
    });

    jLabel34.setText("Ringback:");
    jLabel34.setToolTipText("Must be 8000Hz, 16bit, mono, PCM");

    inRingtone.setAutoscrolls(true);

    outRingtone.setAutoscrolls(true);

    jLabel65.setText("Ringing:");

    selectInRingtone.setText("Select...");
    selectInRingtone.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        selectInRingtoneActionPerformed(evt);
      }
    });

    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(
      jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel2Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(jPanel2Layout.createSequentialGroup()
            .addComponent(jLabel34)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
            .addComponent(outRingtone, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
          .addGroup(jPanel2Layout.createSequentialGroup()
            .addComponent(jLabel65)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(inRingtone, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(selectInRingtone, javax.swing.GroupLayout.Alignment.TRAILING)
          .addComponent(selectOutRingtone, javax.swing.GroupLayout.Alignment.TRAILING))
        .addContainerGap())
    );
    jPanel2Layout.setVerticalGroup(
      jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel2Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel65)
          .addComponent(inRingtone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addComponent(selectInRingtone))
        .addGap(7, 7, 7)
        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel34)
          .addComponent(selectOutRingtone)
          .addComponent(outRingtone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    javax.swing.GroupLayout generalLayout = new javax.swing.GroupLayout(general);
    general.setLayout(generalLayout);
    generalLayout.setHorizontalGroup(
      generalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(generalLayout.createSequentialGroup()
        .addContainerGap()
        .addGroup(generalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
          .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addComponent(jPanel10, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        .addContainerGap(210, Short.MAX_VALUE))
    );
    generalLayout.setVerticalGroup(
      generalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(generalLayout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addGap(283, 283, 283))
    );

    tabs.addTab("General", general);

    jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder("Sound Devices"));

    jLabel20.setText("Audio Input:");

    audioInput.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "<default>" }));

    audioOutput.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "<default>" }));

    jLabel19.setText("Audio Output:");

    javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
    jPanel13.setLayout(jPanel13Layout);
    jPanel13Layout.setHorizontalGroup(
      jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel13Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(jLabel19)
          .addComponent(jLabel20))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(audioOutput, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addComponent(audioInput, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        .addContainerGap())
    );
    jPanel13Layout.setVerticalGroup(
      jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel13Layout.createSequentialGroup()
        .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel19)
          .addComponent(audioOutput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel20)
          .addComponent(audioInput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addGap(0, 8, Short.MAX_VALUE))
    );

    jPanel15.setBorder(javax.swing.BorderFactory.createTitledBorder("Audio Codecs"));

    disabled_audio_codecs.setModel(new javax.swing.AbstractListModel() {
      String[] strings = { "..." };
      public int getSize() { return strings.length; }
      public Object getElementAt(int i) { return strings[i]; }
    });
    disabled_audio_codecs.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    jScrollPane2.setViewportView(disabled_audio_codecs);

    move_audio_codec_up.setText("Up");
    move_audio_codec_up.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        move_audio_codec_upActionPerformed(evt);
      }
    });

    move_audio_codec_down.setText("Down");
    move_audio_codec_down.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        move_audio_codec_downActionPerformed(evt);
      }
    });

    enabled_audio_codecs.setModel(new javax.swing.AbstractListModel() {
      String[] strings = { "..." };
      public int getSize() { return strings.length; }
      public Object getElementAt(int i) { return strings[i]; }
    });
    enabled_audio_codecs.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    jScrollPane3.setViewportView(enabled_audio_codecs);

    jLabel41.setText("Disabled");

    jLabel42.setText("Enabled");

    add_audio_codec.setText("Add ->");
    add_audio_codec.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        add_audio_codecActionPerformed(evt);
      }
    });

    remove_audio_codec.setText("<- Remove");
    remove_audio_codec.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        remove_audio_codecActionPerformed(evt);
      }
    });

    javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
    jPanel15.setLayout(jPanel15Layout);
    jPanel15Layout.setHorizontalGroup(
      jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel15Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addComponent(jLabel41))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
          .addComponent(remove_audio_codec, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addComponent(add_audio_codec, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(jLabel42)
          .addGroup(jPanel15Layout.createSequentialGroup()
            .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(move_audio_codec_down)
              .addComponent(move_audio_codec_up, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))))
        .addContainerGap(18, Short.MAX_VALUE))
    );
    jPanel15Layout.setVerticalGroup(
      jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel15Layout.createSequentialGroup()
        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel41)
          .addComponent(jLabel42))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(jPanel15Layout.createSequentialGroup()
            .addComponent(add_audio_codec)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
            .addComponent(remove_audio_codec)
            .addGap(0, 0, Short.MAX_VALUE))
          .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel15Layout.createSequentialGroup()
            .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
              .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
              .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel15Layout.createSequentialGroup()
                .addComponent(move_audio_codec_up)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(move_audio_codec_down)
                .addGap(0, 11, Short.MAX_VALUE))
              .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
            .addContainerGap())))
    );

    jPanel17.setBorder(javax.swing.BorderFactory.createTitledBorder("Options"));

    jLabel30.setText("Recording Path:");

    selectDownloadPath.setText("Select...");
    selectDownloadPath.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        selectDownloadPathActionPerformed(evt);
      }
    });

    keepAudioOpen.setText("Keep Audio Open");

    javax.swing.GroupLayout jPanel17Layout = new javax.swing.GroupLayout(jPanel17);
    jPanel17.setLayout(jPanel17Layout);
    jPanel17Layout.setHorizontalGroup(
      jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel17Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(jPanel17Layout.createSequentialGroup()
            .addComponent(jLabel30)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(downloadPath, javax.swing.GroupLayout.DEFAULT_SIZE, 226, Short.MAX_VALUE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(selectDownloadPath))
          .addGroup(jPanel17Layout.createSequentialGroup()
            .addComponent(keepAudioOpen)
            .addGap(0, 0, Short.MAX_VALUE)))
        .addContainerGap())
    );
    jPanel17Layout.setVerticalGroup(
      jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel17Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel30)
          .addComponent(downloadPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addComponent(selectDownloadPath))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(keepAudioOpen)
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    javax.swing.GroupLayout audioLayout = new javax.swing.GroupLayout(audio);
    audio.setLayout(audioLayout);
    audioLayout.setHorizontalGroup(
      audioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(audioLayout.createSequentialGroup()
        .addContainerGap()
        .addGroup(audioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
          .addComponent(jPanel15, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addComponent(jPanel13, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addComponent(jPanel17, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        .addContainerGap(148, Short.MAX_VALUE))
    );
    audioLayout.setVerticalGroup(
      audioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(audioLayout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(jPanel17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap())
    );

    tabs.addTab("Audio", audio);

    jPanel14.setBorder(javax.swing.BorderFactory.createTitledBorder("Video System"));

    videoGroup.add(useNativeVideo);
    useNativeVideo.setText("Use Native Video [Windows / Linux]");
    useNativeVideo.addItemListener(new java.awt.event.ItemListener() {
      public void itemStateChanged(java.awt.event.ItemEvent evt) {
        useNativeVideoItemStateChanged(evt);
      }
    });

    videoGroup.add(disableVideo);
    disableVideo.setSelected(true);
    disableVideo.setText("Disable Video");
    disableVideo.addItemListener(new java.awt.event.ItemListener() {
      public void itemStateChanged(java.awt.event.ItemEvent evt) {
        disableVideoItemStateChanged(evt);
      }
    });

    jLabel33.setText("Device:");

    videoDevice.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "<default>" }));

    videoFPS.setMajorTickSpacing(5);
    videoFPS.setMaximum(30);
    videoFPS.setMinimum(5);
    videoFPS.setMinorTickSpacing(1);
    videoFPS.setPaintLabels(true);
    videoFPS.setPaintTicks(true);
    videoFPS.setSnapToTicks(true);
    videoFPS.setValue(10);

    jLabel32.setText("FPS");

    javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
    jPanel14.setLayout(jPanel14Layout);
    jPanel14Layout.setHorizontalGroup(
      jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel14Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
          .addComponent(useNativeVideo)
          .addComponent(disableVideo)
          .addGroup(jPanel14Layout.createSequentialGroup()
            .addComponent(jLabel33)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(videoDevice, javax.swing.GroupLayout.PREFERRED_SIZE, 317, javax.swing.GroupLayout.PREFERRED_SIZE))
          .addGroup(jPanel14Layout.createSequentialGroup()
            .addComponent(jLabel32)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(videoFPS, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    jPanel14Layout.setVerticalGroup(
      jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel14Layout.createSequentialGroup()
        .addContainerGap()
        .addComponent(disableVideo)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(useNativeVideo)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel33)
          .addComponent(videoDevice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(videoFPS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addComponent(jLabel32))
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    jPanel18.setBorder(javax.swing.BorderFactory.createTitledBorder("Video Codecs"));

    disabled_video_codecs.setModel(new javax.swing.AbstractListModel() {
      String[] strings = { "..." };
      public int getSize() { return strings.length; }
      public Object getElementAt(int i) { return strings[i]; }
    });
    disabled_video_codecs.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    jScrollPane4.setViewportView(disabled_video_codecs);

    move_video_codec_up.setText("Up");
    move_video_codec_up.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        move_video_codec_upActionPerformed(evt);
      }
    });

    move_video_codec_down.setText("Down");
    move_video_codec_down.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        move_video_codec_downActionPerformed(evt);
      }
    });

    enabled_video_codecs.setModel(new javax.swing.AbstractListModel() {
      String[] strings = { "..." };
      public int getSize() { return strings.length; }
      public Object getElementAt(int i) { return strings[i]; }
    });
    enabled_video_codecs.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    jScrollPane5.setViewportView(enabled_video_codecs);

    jLabel46.setText("Disabled");

    jLabel47.setText("Enabled");

    add_video_codec.setText("Add ->");
    add_video_codec.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        add_video_codecActionPerformed(evt);
      }
    });

    remove_video_codec.setText("<- Remove");
    remove_video_codec.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        remove_video_codecActionPerformed(evt);
      }
    });

    javax.swing.GroupLayout jPanel18Layout = new javax.swing.GroupLayout(jPanel18);
    jPanel18.setLayout(jPanel18Layout);
    jPanel18Layout.setHorizontalGroup(
      jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel18Layout.createSequentialGroup()
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addComponent(jLabel46))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
          .addComponent(remove_video_codec, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addComponent(add_video_codec, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(jLabel47)
          .addGroup(jPanel18Layout.createSequentialGroup()
            .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(move_video_codec_down)
              .addComponent(move_video_codec_up, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)))))
    );
    jPanel18Layout.setVerticalGroup(
      jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel18Layout.createSequentialGroup()
        .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel46)
          .addComponent(jLabel47))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(jPanel18Layout.createSequentialGroup()
            .addComponent(add_video_codec)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
            .addComponent(remove_video_codec)
            .addGap(0, 0, Short.MAX_VALUE))
          .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel18Layout.createSequentialGroup()
            .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
              .addComponent(jScrollPane5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
              .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel18Layout.createSequentialGroup()
                .addComponent(move_video_codec_up)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(move_video_codec_down)
                .addGap(0, 0, Short.MAX_VALUE))
              .addComponent(jScrollPane4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
            .addContainerGap())))
    );

    javax.swing.GroupLayout videoLayout = new javax.swing.GroupLayout(video);
    video.setLayout(videoLayout);
    videoLayout.setHorizontalGroup(
      videoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(videoLayout.createSequentialGroup()
        .addContainerGap()
        .addGroup(videoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
          .addComponent(jPanel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addComponent(jPanel18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        .addContainerGap(167, Short.MAX_VALUE))
    );
    videoLayout.setVerticalGroup(
      videoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(videoLayout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addGap(2, 2, 2)
        .addComponent(jPanel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap(188, Short.MAX_VALUE))
    );

    tabs.addTab("Video", video);

    jLabel1.setText("Username");
    jLabel1.setToolTipText("Username / Extension / Phone Number");

    jLabel2.setText("Password");
    jLabel2.setToolTipText("SIP Password");

    jLabel3.setText("Domain");
    jLabel3.setToolTipText("Domain / Host / IP");

    jLabel23.setText("Auth name");
    jLabel23.setToolTipText("Alternative Authorization Username (optional)");

    l1disableVideo.setText("Disable Video");

    l1secure.setText("Enable Encryption");
    l1secure.setToolTipText("SRTP");

    jLabel29.setText("SIP Transport");

    l1sip.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "UDP", "TCP", "TLS" }));

    jLabel56.setText("Encryption Key Exchange");

    l1key.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SDP", "DTLS" }));

    jLabel31.setText("Display name");
    jLabel31.setToolTipText("Display Name (optional)");

    l1siplog.setText("Log SIP Messages");

    javax.swing.GroupLayout l1Layout = new javax.swing.GroupLayout(l1);
    l1.setLayout(l1Layout);
    l1Layout.setHorizontalGroup(
      l1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(l1Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(l1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(l1Layout.createSequentialGroup()
            .addGroup(l1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(jLabel23)
              .addComponent(jLabel1)
              .addComponent(jLabel2)
              .addComponent(jLabel3)
              .addComponent(jLabel31))
            .addGap(32, 32, 32)
            .addGroup(l1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(l1name)
              .addComponent(l1pass, javax.swing.GroupLayout.Alignment.TRAILING)
              .addComponent(l1auth, javax.swing.GroupLayout.Alignment.TRAILING)
              .addComponent(l1user)
              .addComponent(l1host)))
          .addGroup(l1Layout.createSequentialGroup()
            .addGroup(l1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(l1secure)
              .addComponent(l1disableVideo)
              .addGroup(l1Layout.createSequentialGroup()
                .addComponent(jLabel29)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(l1sip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
              .addGroup(l1Layout.createSequentialGroup()
                .addComponent(jLabel56)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(l1key, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
              .addComponent(l1siplog))
            .addGap(0, 356, Short.MAX_VALUE)))
        .addContainerGap())
    );
    l1Layout.setVerticalGroup(
      l1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(l1Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(l1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel31)
          .addComponent(l1name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel1)
          .addComponent(l1user, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel23)
          .addComponent(l1auth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel2)
          .addComponent(l1pass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel3)
          .addComponent(l1host, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(l1disableVideo)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(l1secure)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel29)
          .addComponent(l1sip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel56)
          .addComponent(l1key, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(l1siplog)
        .addContainerGap(164, Short.MAX_VALUE))
    );

    jTabbedPane1.addTab("Line1", l1);

    jLabel4.setText("Username");

    jLabel5.setText("Password");

    jLabel6.setText("Domain");

    l2same.setText("same as ");
    l2same.addItemListener(new java.awt.event.ItemListener() {
      public void itemStateChanged(java.awt.event.ItemEvent evt) {
        l2sameItemStateChanged(evt);
      }
    });

    l2sameidx.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Line 1", "Line 3", "Line 4", "Line 5", "Line 6" }));

    jLabel24.setText("Auth name");

    l2disableVideo.setText("Disable Video");

    l2secure.setText("Enable Encryption");
    l2secure.setToolTipText("SRTP");

    jLabel37.setText("SIP Transport");

    l2sip.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "UDP", "TCP", "TLS" }));

    jLabel57.setText("Encryption Key Exchange");

    l2key.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SDP", "DTLS" }));

    jLabel44.setText("Display name");

    l2siplog.setText("Log SIP Messages");

    javax.swing.GroupLayout l2Layout = new javax.swing.GroupLayout(l2);
    l2.setLayout(l2Layout);
    l2Layout.setHorizontalGroup(
      l2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(l2Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(l2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(l2Layout.createSequentialGroup()
            .addGroup(l2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(jLabel24)
              .addComponent(jLabel5)
              .addComponent(jLabel6)
              .addComponent(jLabel4)
              .addComponent(jLabel44))
            .addGap(18, 18, 18)
            .addGroup(l2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(l2name)
              .addComponent(l2pass, javax.swing.GroupLayout.Alignment.TRAILING)
              .addComponent(l2auth, javax.swing.GroupLayout.Alignment.TRAILING)
              .addComponent(l2user)
              .addComponent(l2host)))
          .addGroup(l2Layout.createSequentialGroup()
            .addGroup(l2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(l2siplog)
              .addComponent(l2secure)
              .addComponent(l2disableVideo)
              .addGroup(l2Layout.createSequentialGroup()
                .addComponent(l2same)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(l2sameidx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
              .addGroup(l2Layout.createSequentialGroup()
                .addComponent(jLabel37)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(l2sip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
              .addGroup(l2Layout.createSequentialGroup()
                .addComponent(jLabel57)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(l2key, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
            .addGap(0, 356, Short.MAX_VALUE)))
        .addContainerGap())
    );
    l2Layout.setVerticalGroup(
      l2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(l2Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(l2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(l2same)
          .addComponent(l2sameidx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel44)
          .addComponent(l2name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel4)
          .addComponent(l2user, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel24)
          .addComponent(l2auth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel5)
          .addComponent(l2pass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel6)
          .addComponent(l2host, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addComponent(l2disableVideo)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(l2secure)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel37)
          .addComponent(l2sip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel57)
          .addComponent(l2key, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(l2siplog)
        .addContainerGap(133, Short.MAX_VALUE))
    );

    jTabbedPane1.addTab("Line2", l2);

    l3same.setText("same as ");
    l3same.addItemListener(new java.awt.event.ItemListener() {
      public void itemStateChanged(java.awt.event.ItemEvent evt) {
        l3sameItemStateChanged(evt);
      }
    });

    l3sameidx.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Line 1", "Line 2", "Line 4", "Line 5", "Line 6" }));

    jLabel7.setText("Username");

    jLabel8.setText("Password");

    jLabel9.setText("Domain");

    jLabel25.setText("Auth name");

    l3disableVideo.setText("Disable Video");

    l3secure.setText("Enable Encryption");
    l3secure.setToolTipText("SRTP");

    jLabel52.setText("SIP Transport");

    l3sip.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "UDP", "TCP", "TLS" }));

    jLabel58.setText("Encryption Key Exchange");

    l3key.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SDP", "DTLS" }));

    jLabel45.setText("Display name");

    l3siplog.setText("Log SIP Messages");

    javax.swing.GroupLayout l3Layout = new javax.swing.GroupLayout(l3);
    l3.setLayout(l3Layout);
    l3Layout.setHorizontalGroup(
      l3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(l3Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(l3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(l3Layout.createSequentialGroup()
            .addGroup(l3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(jLabel25)
              .addComponent(jLabel7)
              .addComponent(jLabel8)
              .addComponent(jLabel9)
              .addComponent(jLabel45))
            .addGap(18, 18, 18)
            .addGroup(l3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(l3name)
              .addComponent(l3pass, javax.swing.GroupLayout.Alignment.TRAILING)
              .addComponent(l3auth, javax.swing.GroupLayout.Alignment.TRAILING)
              .addComponent(l3user)
              .addComponent(l3host)))
          .addGroup(l3Layout.createSequentialGroup()
            .addGroup(l3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(l3secure)
              .addComponent(l3disableVideo)
              .addGroup(l3Layout.createSequentialGroup()
                .addComponent(l3same)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(l3sameidx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
              .addGroup(l3Layout.createSequentialGroup()
                .addComponent(jLabel52)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(l3sip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
              .addGroup(l3Layout.createSequentialGroup()
                .addComponent(jLabel58)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(l3key, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
              .addComponent(l3siplog))
            .addGap(0, 356, Short.MAX_VALUE)))
        .addContainerGap())
    );
    l3Layout.setVerticalGroup(
      l3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(l3Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(l3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(l3same)
          .addComponent(l3sameidx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel45)
          .addComponent(l3name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel7)
          .addComponent(l3user, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel25)
          .addComponent(l3auth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel8)
          .addComponent(l3pass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel9)
          .addComponent(l3host, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addComponent(l3disableVideo)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(l3secure)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel52)
          .addComponent(l3sip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel58)
          .addComponent(l3key, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(l3siplog)
        .addContainerGap(133, Short.MAX_VALUE))
    );

    jTabbedPane1.addTab("Line3", l3);

    l4same.setText("same as ");
    l4same.addItemListener(new java.awt.event.ItemListener() {
      public void itemStateChanged(java.awt.event.ItemEvent evt) {
        l4sameItemStateChanged(evt);
      }
    });

    l4sameidx.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Line 1", "Line 2", "Line 3", "Line 5", "Line 6" }));

    jLabel10.setText("Username");

    jLabel11.setText("Password");

    jLabel12.setText("Domain");

    jLabel26.setText("Auth name");

    l4disableVideo.setText("Disable Video");

    l4secure.setText("Enable Encryption");
    l4secure.setToolTipText("SRTP");

    jLabel53.setText("SIP Transport");

    l4sip.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "UDP", "TCP", "TLS" }));

    jLabel59.setText("Encryption Key Exchange");

    l4key.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SDP", "DTLS" }));

    jLabel66.setText("Display name");

    l4siplog.setText("Log SIP Messages");

    javax.swing.GroupLayout l4Layout = new javax.swing.GroupLayout(l4);
    l4.setLayout(l4Layout);
    l4Layout.setHorizontalGroup(
      l4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(l4Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(l4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(l4Layout.createSequentialGroup()
            .addGroup(l4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(jLabel26)
              .addComponent(jLabel11)
              .addComponent(jLabel12)
              .addComponent(jLabel10)
              .addComponent(jLabel66))
            .addGap(18, 18, 18)
            .addGroup(l4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(l4name)
              .addComponent(l4pass, javax.swing.GroupLayout.Alignment.TRAILING)
              .addComponent(l4auth, javax.swing.GroupLayout.Alignment.TRAILING)
              .addComponent(l4user)
              .addComponent(l4host)))
          .addGroup(l4Layout.createSequentialGroup()
            .addGroup(l4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(l4siplog)
              .addComponent(l4secure)
              .addGroup(l4Layout.createSequentialGroup()
                .addComponent(l4same)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(l4sameidx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
              .addComponent(l4disableVideo)
              .addGroup(l4Layout.createSequentialGroup()
                .addComponent(jLabel53)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(l4sip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
              .addGroup(l4Layout.createSequentialGroup()
                .addComponent(jLabel59)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(l4key, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
            .addGap(0, 356, Short.MAX_VALUE)))
        .addContainerGap())
    );
    l4Layout.setVerticalGroup(
      l4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(l4Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(l4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(l4same)
          .addComponent(l4sameidx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel66)
          .addComponent(l4name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel10)
          .addComponent(l4user, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel26)
          .addComponent(l4auth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel11)
          .addComponent(l4pass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel12)
          .addComponent(l4host, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addComponent(l4disableVideo)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(l4secure)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel53)
          .addComponent(l4sip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel59)
          .addComponent(l4key, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(l4siplog)
        .addContainerGap(133, Short.MAX_VALUE))
    );

    jTabbedPane1.addTab("Line4", l4);

    l5same.setText("same as ");
    l5same.addItemListener(new java.awt.event.ItemListener() {
      public void itemStateChanged(java.awt.event.ItemEvent evt) {
        l5sameItemStateChanged(evt);
      }
    });

    l5sameidx.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Line 1", "Line 2", "Line 3", "Line 4", "Line 6" }));

    jLabel13.setText("Username");

    jLabel14.setText("Password");

    jLabel15.setText("Domain");

    jLabel27.setText("Auth name");

    l5disableVideo.setText("Disable Video");

    l5secure.setText("Enable Encryption");
    l5secure.setToolTipText("SRTP");

    jLabel54.setText("SIP Transport");

    l5sip.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "UDP", "TCP", "TLS" }));

    jLabel60.setText("Encryption Key Exchange");

    l5key.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SDP", "DTLS" }));

    jLabel67.setText("Display name");

    l5siplog.setText("Log SIP Messages");

    javax.swing.GroupLayout l5Layout = new javax.swing.GroupLayout(l5);
    l5.setLayout(l5Layout);
    l5Layout.setHorizontalGroup(
      l5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(l5Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(l5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(l5Layout.createSequentialGroup()
            .addGroup(l5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(jLabel27)
              .addComponent(jLabel14)
              .addComponent(jLabel15)
              .addComponent(jLabel13)
              .addComponent(jLabel67))
            .addGap(18, 18, 18)
            .addGroup(l5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(l5name)
              .addComponent(l5pass, javax.swing.GroupLayout.Alignment.TRAILING)
              .addComponent(l5auth, javax.swing.GroupLayout.Alignment.TRAILING)
              .addComponent(l5user)
              .addComponent(l5host, javax.swing.GroupLayout.Alignment.TRAILING)))
          .addGroup(l5Layout.createSequentialGroup()
            .addGroup(l5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(l5siplog)
              .addComponent(l5secure)
              .addComponent(l5disableVideo)
              .addGroup(l5Layout.createSequentialGroup()
                .addComponent(l5same)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(l5sameidx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
              .addGroup(l5Layout.createSequentialGroup()
                .addComponent(jLabel54)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(l5sip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
              .addGroup(l5Layout.createSequentialGroup()
                .addComponent(jLabel60)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(l5key, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
            .addGap(0, 356, Short.MAX_VALUE)))
        .addContainerGap())
    );
    l5Layout.setVerticalGroup(
      l5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(l5Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(l5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(l5same)
          .addComponent(l5sameidx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel67)
          .addComponent(l5name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel13)
          .addComponent(l5user, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel27)
          .addComponent(l5auth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel14)
          .addComponent(l5pass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel15)
          .addComponent(l5host, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addComponent(l5disableVideo)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(l5secure)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel54)
          .addComponent(l5sip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel60)
          .addComponent(l5key, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(l5siplog)
        .addContainerGap(133, Short.MAX_VALUE))
    );

    jTabbedPane1.addTab("Line5", l5);

    l6same.setText("same as ");
    l6same.addItemListener(new java.awt.event.ItemListener() {
      public void itemStateChanged(java.awt.event.ItemEvent evt) {
        l6sameItemStateChanged(evt);
      }
    });

    l6sameidx.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Line 1", "Line 2", "Line 3", "Line 4", "Line 5", "Line 6" }));

    jLabel16.setText("Username");

    jLabel17.setText("Password");

    jLabel18.setText("Domain");

    jLabel28.setText("Auth name");

    l6disableVideo.setText("Disable Video");

    l6secure.setText("Enable Encryption");
    l6secure.setToolTipText("SRTP");

    jLabel55.setText("SIP Transport");

    l6sip.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "UDP", "TCP", "TLS" }));

    jLabel61.setText("Encryption Key Exchange");

    l6key.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SDP", "DTLS" }));

    jLabel68.setText("Display name");

    l6siplog.setText("Log SIP Messages");

    javax.swing.GroupLayout l6Layout = new javax.swing.GroupLayout(l6);
    l6.setLayout(l6Layout);
    l6Layout.setHorizontalGroup(
      l6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(l6Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(l6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(l6Layout.createSequentialGroup()
            .addGroup(l6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(jLabel28)
              .addComponent(jLabel17)
              .addComponent(jLabel18)
              .addComponent(jLabel16)
              .addComponent(jLabel68))
            .addGap(18, 18, 18)
            .addGroup(l6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(l6name)
              .addComponent(l6pass, javax.swing.GroupLayout.Alignment.TRAILING)
              .addComponent(l6auth, javax.swing.GroupLayout.Alignment.TRAILING)
              .addComponent(l6user)
              .addComponent(l6host)))
          .addGroup(l6Layout.createSequentialGroup()
            .addGroup(l6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(l6siplog)
              .addComponent(l6secure)
              .addGroup(l6Layout.createSequentialGroup()
                .addComponent(l6same)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(l6sameidx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
              .addComponent(l6disableVideo)
              .addGroup(l6Layout.createSequentialGroup()
                .addComponent(jLabel55)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(l6sip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
              .addGroup(l6Layout.createSequentialGroup()
                .addComponent(jLabel61)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(l6key, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
            .addGap(0, 356, Short.MAX_VALUE)))
        .addContainerGap())
    );
    l6Layout.setVerticalGroup(
      l6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(l6Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(l6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(l6same)
          .addComponent(l6sameidx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel68)
          .addComponent(l6name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel16)
          .addComponent(l6user, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel28)
          .addComponent(l6auth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel17)
          .addComponent(l6pass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel18)
          .addComponent(l6host, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addComponent(l6disableVideo)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(l6secure)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel55)
          .addComponent(l6sip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(l6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel61)
          .addComponent(l6key, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(l6siplog)
        .addContainerGap(133, Short.MAX_VALUE))
    );

    jTabbedPane1.addTab("Line6", l6);

    javax.swing.GroupLayout acctsLayout = new javax.swing.GroupLayout(accts);
    accts.setLayout(acctsLayout);
    acctsLayout.setHorizontalGroup(
      acctsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(acctsLayout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jTabbedPane1)
        .addContainerGap())
    );
    acctsLayout.setVerticalGroup(
      acctsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(acctsLayout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jTabbedPane1)
        .addContainerGap())
    );

    tabs.addTab("Accounts", accts);

    jPanel21.setBorder(javax.swing.BorderFactory.createTitledBorder("Firewall Traversal"));

    natGroup.add(natNone);
    natNone.setText("None (use local IP)");

    natGroup.add(natStun);
    natStun.setText("STUN (detect public IP/port)");

    natGroup.add(natTurn);
    natTurn.setText("TURN (relay RTP data)");

    natGroup.add(natIce);
    natIce.setText("ICE (STUN + TURN)");

    natPrivate.setText("Use STUN even if SIP Server is on private network");
    natPrivate.setToolTipText("Private networks include 192.168.x.x, 10.x.x.x and 172.16-31.x.x");

    jLabel39.setText("Server:");

    jLabel49.setText("User:");

    jLabel50.setText("Pass:");

    rport.setText("Use rport (detect public port)");
    rport.setToolTipText("Determine public port as seen by server.");

    received.setText("Use received (detect public IP)");
    received.setToolTipText("Determine public IP as seen by server.");

    javax.swing.GroupLayout jPanel21Layout = new javax.swing.GroupLayout(jPanel21);
    jPanel21.setLayout(jPanel21Layout);
    jPanel21Layout.setHorizontalGroup(
      jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel21Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(received)
          .addGroup(jPanel21Layout.createSequentialGroup()
            .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(jLabel39)
              .addComponent(jLabel49)
              .addComponent(jLabel50))
            .addGap(4, 4, 4)
            .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
              .addComponent(natUser, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
              .addComponent(natHost)
              .addComponent(natPass)))
          .addComponent(natNone)
          .addComponent(natStun)
          .addComponent(natTurn)
          .addComponent(natIce)
          .addComponent(rport)
          .addComponent(natPrivate))
        .addContainerGap(28, Short.MAX_VALUE))
    );
    jPanel21Layout.setVerticalGroup(
      jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel21Layout.createSequentialGroup()
        .addContainerGap()
        .addComponent(natNone)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(natStun)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(natTurn)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(natIce)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel39)
          .addComponent(natHost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel49)
          .addComponent(natUser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel50)
          .addComponent(natPass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(natPrivate)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(received)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(rport)
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    jPanel22.setBorder(javax.swing.BorderFactory.createTitledBorder("Port Ranges"));

    sipRange.setText("SIP Port Range");
    sipRange.addChangeListener(new javax.swing.event.ChangeListener() {
      public void stateChanged(javax.swing.event.ChangeEvent evt) {
        sipRangeStateChanged(evt);
      }
    });

    sipmin.setText("5070");
    sipmin.setEnabled(false);

    jLabel43.setText("to");

    sipmax.setText("5199");
    sipmax.setEnabled(false);

    rtpRange.setText("RTP Port Range");
    rtpRange.addChangeListener(new javax.swing.event.ChangeListener() {
      public void stateChanged(javax.swing.event.ChangeEvent evt) {
        rtpRangeStateChanged(evt);
      }
    });

    rtpmin.setText("32768");
    rtpmin.setEnabled(false);

    jLabel48.setText("to");

    rtpmax.setText("65535");
    rtpmax.setEnabled(false);

    javax.swing.GroupLayout jPanel22Layout = new javax.swing.GroupLayout(jPanel22);
    jPanel22.setLayout(jPanel22Layout);
    jPanel22Layout.setHorizontalGroup(
      jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel22Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(rtpRange)
          .addComponent(sipRange))
        .addGap(18, 18, 18)
        .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
          .addComponent(rtpmin, javax.swing.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
          .addComponent(sipmin))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(jLabel43)
          .addComponent(jLabel48))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
          .addComponent(sipmax)
          .addComponent(rtpmax, javax.swing.GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE))
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    jPanel22Layout.setVerticalGroup(
      jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel22Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(sipRange)
          .addComponent(sipmin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addComponent(jLabel43)
          .addComponent(sipmax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(rtpRange)
          .addComponent(rtpmin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addComponent(jLabel48)
          .addComponent(rtpmax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    javax.swing.GroupLayout topologyLayout = new javax.swing.GroupLayout(topology);
    topology.setLayout(topologyLayout);
    topologyLayout.setHorizontalGroup(
      topologyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(topologyLayout.createSequentialGroup()
        .addContainerGap()
        .addGroup(topologyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
          .addComponent(jPanel22, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addComponent(jPanel21, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        .addContainerGap(249, Short.MAX_VALUE))
    );
    topologyLayout.setVerticalGroup(
      topologyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(topologyLayout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jPanel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(jPanel22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap(83, Short.MAX_VALUE))
    );

    tabs.addTab("Topology", topology);

    jLabel62.setText("In order to use DTLS Key Exchange you must generate a Certificate / Key pair");

    jLabel63.setText("Your current key is : ");

    keyStatus.setText("???");

    genCertKey.setText("Generate Self-Signed Cert/Key Pair");
    genCertKey.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        genCertKeyActionPerformed(evt);
      }
    });

    jLabel64.setText("dname");

    dname.setText("CN=jfphone.sourceforge.net, OU=user, O=jfphone, C=CA");

    javax.swing.GroupLayout eKeyLayout = new javax.swing.GroupLayout(eKey);
    eKey.setLayout(eKeyLayout);
    eKeyLayout.setHorizontalGroup(
      eKeyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(eKeyLayout.createSequentialGroup()
        .addContainerGap()
        .addGroup(eKeyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(eKeyLayout.createSequentialGroup()
            .addComponent(jLabel64)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(dname))
          .addGroup(eKeyLayout.createSequentialGroup()
            .addGroup(eKeyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(jLabel62)
              .addGroup(eKeyLayout.createSequentialGroup()
                .addComponent(jLabel63)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(keyStatus))
              .addComponent(genCertKey))
            .addGap(0, 181, Short.MAX_VALUE)))
        .addContainerGap())
    );
    eKeyLayout.setVerticalGroup(
      eKeyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(eKeyLayout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jLabel62)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(eKeyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel63)
          .addComponent(keyStatus))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(genCertKey)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(eKeyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(jLabel64)
          .addComponent(dname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addContainerGap(370, Short.MAX_VALUE))
    );

    tabs.addTab("Keys", eKey);

    about.setColumns(20);
    about.setEditable(false);
    about.setRows(5);
    about.setText("...");
    jScrollPane1.setViewportView(about);

    javax.swing.GroupLayout aboutTabLayout = new javax.swing.GroupLayout(aboutTab);
    aboutTab.setLayout(aboutTabLayout);
    aboutTabLayout.setHorizontalGroup(
      aboutTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 576, Short.MAX_VALUE)
      .addGroup(aboutTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(aboutTabLayout.createSequentialGroup()
          .addContainerGap()
          .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 556, Short.MAX_VALUE)
          .addContainerGap()))
    );
    aboutTabLayout.setVerticalGroup(
      aboutTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 470, Short.MAX_VALUE)
      .addGroup(aboutTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(aboutTabLayout.createSequentialGroup()
          .addContainerGap()
          .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 448, Short.MAX_VALUE)
          .addContainerGap()))
    );

    tabs.addTab("About", aboutTab);

    help.setText("Online Help");
    help.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        helpActionPerformed(evt);
      }
    });

    jButton1.setText("Donate");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButton1ActionPerformed(evt);
      }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(tabs)
          .addGroup(layout.createSequentialGroup()
            .addComponent(bSave)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(bCancel)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jButton1)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(help)))
        .addContainerGap())
    );
    layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
        .addContainerGap()
        .addComponent(tabs, javax.swing.GroupLayout.PREFERRED_SIZE, 498, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(bSave)
          .addComponent(bCancel)
          .addComponent(help)
          .addComponent(jButton1))
        .addContainerGap())
    );

    pack();
  }// </editor-fold>//GEN-END:initComponents

  private void bSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bSaveActionPerformed
    if (!validFields()) return;
    saveSettings();
    Settings.saveSettings();
    dispose();
  }//GEN-LAST:event_bSaveActionPerformed

  private void bCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bCancelActionPerformed
    dispose();
  }//GEN-LAST:event_bCancelActionPerformed

  private void selectDownloadPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectDownloadPathActionPerformed
    selectDownloadPath();
  }//GEN-LAST:event_selectDownloadPathActionPerformed

  private void add_audio_codecActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_add_audio_codecActionPerformed
    int idx = disabled_audio_codecs.getSelectedIndex();
    if (idx == -1) return;
    enabledAudioCodecsList.addElement((String)disabledAudioCodecsList.remove(idx));
  }//GEN-LAST:event_add_audio_codecActionPerformed

  private void remove_audio_codecActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_remove_audio_codecActionPerformed
    int idx = enabled_audio_codecs.getSelectedIndex();
    if (idx == -1) return;
    disabledAudioCodecsList.addElement((String)enabledAudioCodecsList.remove(idx));
  }//GEN-LAST:event_remove_audio_codecActionPerformed

  private void move_audio_codec_upActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_move_audio_codec_upActionPerformed
    int idx = enabled_audio_codecs.getSelectedIndex();
    if ((idx == -1) || (idx == 0)) return;
    enabledAudioCodecsList.add(idx-1, (String)enabledAudioCodecsList.remove(idx));
  }//GEN-LAST:event_move_audio_codec_upActionPerformed

  private void move_audio_codec_downActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_move_audio_codec_downActionPerformed
    int cnt = enabledAudioCodecsList.getSize();
    int idx = enabled_audio_codecs.getSelectedIndex();
    if ((idx == -1) || (idx == cnt-1)) return;
    enabledAudioCodecsList.add(idx+1, (String)enabledAudioCodecsList.remove(idx));
  }//GEN-LAST:event_move_audio_codec_downActionPerformed

  private void move_video_codec_upActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_move_video_codec_upActionPerformed
    int idx = enabled_video_codecs.getSelectedIndex();
    if ((idx == -1) || (idx == 0)) return;
    enabledVideoCodecsList.add(idx-1, (String)enabledVideoCodecsList.remove(idx));
  }//GEN-LAST:event_move_video_codec_upActionPerformed

  private void move_video_codec_downActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_move_video_codec_downActionPerformed
    int cnt = enabledVideoCodecsList.getSize();
    int idx = enabled_video_codecs.getSelectedIndex();
    if ((idx == -1) || (idx == cnt-1)) return;
    enabledVideoCodecsList.add(idx+1, (String)enabledVideoCodecsList.remove(idx));
  }//GEN-LAST:event_move_video_codec_downActionPerformed

  private void add_video_codecActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_add_video_codecActionPerformed
    int idx = disabled_video_codecs.getSelectedIndex();
    if (idx == -1) return;
    enabledVideoCodecsList.addElement((String)disabledVideoCodecsList.remove(idx));
  }//GEN-LAST:event_add_video_codecActionPerformed

  private void remove_video_codecActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_remove_video_codecActionPerformed
    int idx = enabled_video_codecs.getSelectedIndex();
    if (idx == -1) return;
    disabledVideoCodecsList.addElement((String)enabledVideoCodecsList.remove(idx));
  }//GEN-LAST:event_remove_video_codecActionPerformed

  private void disableVideoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_disableVideoItemStateChanged
    updateVideo();
  }//GEN-LAST:event_disableVideoItemStateChanged

  private void useNativeVideoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_useNativeVideoItemStateChanged
    updateVideo();
  }//GEN-LAST:event_useNativeVideoItemStateChanged

  private void sipRangeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sipRangeStateChanged
    boolean state = sipRange.isSelected();
    sipmin.setEnabled(state);
    sipmax.setEnabled(state);
  }//GEN-LAST:event_sipRangeStateChanged

  private void rtpRangeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_rtpRangeStateChanged
    boolean state = rtpRange.isSelected();
    rtpmin.setEnabled(state);
    rtpmax.setEnabled(state);
  }//GEN-LAST:event_rtpRangeStateChanged

  private void l2sameItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_l2sameItemStateChanged
    boolean state = !l2same.isSelected();
    l2name.setEnabled(state);
    l2user.setEnabled(state);
    l2auth.setEnabled(state);
    l2pass.setEnabled(state);
    l2host.setEnabled(state);
    l2disableVideo.setEnabled(state);
    l2secure.setEnabled(state);
    l2sip.setEnabled(state);
    l2key.setEnabled(state);
    l2siplog.setEnabled(state);
  }//GEN-LAST:event_l2sameItemStateChanged

  private void l3sameItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_l3sameItemStateChanged
    boolean state = !l3same.isSelected();
    l3name.setEnabled(state);
    l3user.setEnabled(state);
    l3auth.setEnabled(state);
    l3pass.setEnabled(state);
    l3host.setEnabled(state);
    l3disableVideo.setEnabled(state);
    l3secure.setEnabled(state);
    l3sip.setEnabled(state);
    l3key.setEnabled(state);
    l3siplog.setEnabled(state);
  }//GEN-LAST:event_l3sameItemStateChanged

  private void l4sameItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_l4sameItemStateChanged
    boolean state = !l4same.isSelected();
    l4name.setEnabled(state);
    l4user.setEnabled(state);
    l4auth.setEnabled(state);
    l4pass.setEnabled(state);
    l4host.setEnabled(state);
    l4disableVideo.setEnabled(state);
    l4secure.setEnabled(state);
    l4sip.setEnabled(state);
    l4key.setEnabled(state);
    l4siplog.setEnabled(state);
  }//GEN-LAST:event_l4sameItemStateChanged

  private void l5sameItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_l5sameItemStateChanged
    boolean state = !l5same.isSelected();
    l5name.setEnabled(state);
    l5user.setEnabled(state);
    l5auth.setEnabled(state);
    l5pass.setEnabled(state);
    l5host.setEnabled(state);
    l5disableVideo.setEnabled(state);
    l5secure.setEnabled(state);
    l5sip.setEnabled(state);
    l5key.setEnabled(state);
    l5siplog.setEnabled(state);
  }//GEN-LAST:event_l5sameItemStateChanged

  private void l6sameItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_l6sameItemStateChanged
    boolean state = !l6same.isSelected();
    l6name.setEnabled(state);
    l6user.setEnabled(state);
    l6auth.setEnabled(state);
    l6pass.setEnabled(state);
    l6host.setEnabled(state);
    l6disableVideo.setEnabled(state);
    l6secure.setEnabled(state);
    l6sip.setEnabled(state);
    l6key.setEnabled(state);
    l6siplog.setEnabled(state);
  }//GEN-LAST:event_l6sameItemStateChanged

  private void genCertKeyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_genCertKeyActionPerformed
    genKeys();
  }//GEN-LAST:event_genCertKeyActionPerformed

  private void selectInRingtoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectInRingtoneActionPerformed
    selectInRingtoneFilename();
  }//GEN-LAST:event_selectInRingtoneActionPerformed

  private void selectOutRingtoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectOutRingtoneActionPerformed
    selectOutRingtoneFilename();
  }//GEN-LAST:event_selectOutRingtoneActionPerformed

  private void helpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpActionPerformed
    JFAWT.openURL("http://jfphone.sourceforge.net/help.php");
  }//GEN-LAST:event_helpActionPerformed

  private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    JFAWT.donate();
  }//GEN-LAST:event_jButton1ActionPerformed

  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JTextArea about;
  private javax.swing.JPanel aboutTab;
  private javax.swing.JPanel accts;
  private javax.swing.JButton add_audio_codec;
  private javax.swing.JButton add_video_codec;
  private javax.swing.JCheckBox alwaysOnTop;
  private javax.swing.JPanel audio;
  private javax.swing.JComboBox audioInput;
  private javax.swing.JComboBox audioOutput;
  private javax.swing.JCheckBox autohold;
  private javax.swing.JButton bCancel;
  private javax.swing.JButton bSave;
  private javax.swing.JCheckBox checkVersion;
  private javax.swing.JCheckBox disableLogging;
  private javax.swing.JRadioButton disableVideo;
  private javax.swing.JList disabled_audio_codecs;
  private javax.swing.JList disabled_video_codecs;
  private javax.swing.JTextField dname;
  private javax.swing.JTextField dndCodeOff;
  private javax.swing.JTextField dndCodeOn;
  private javax.swing.JTextField downloadPath;
  private javax.swing.JPanel eKey;
  private javax.swing.JList enabled_audio_codecs;
  private javax.swing.JList enabled_video_codecs;
  private javax.swing.JCheckBox exitWhenClosed;
  private javax.swing.JButton genCertKey;
  private javax.swing.JPanel general;
  private javax.swing.JButton help;
  private javax.swing.JCheckBox hideWhenMinimized;
  private javax.swing.JComboBox inRingtone;
  private javax.swing.JButton jButton1;
  private javax.swing.JLabel jLabel1;
  private javax.swing.JLabel jLabel10;
  private javax.swing.JLabel jLabel11;
  private javax.swing.JLabel jLabel12;
  private javax.swing.JLabel jLabel13;
  private javax.swing.JLabel jLabel14;
  private javax.swing.JLabel jLabel15;
  private javax.swing.JLabel jLabel16;
  private javax.swing.JLabel jLabel17;
  private javax.swing.JLabel jLabel18;
  private javax.swing.JLabel jLabel19;
  private javax.swing.JLabel jLabel2;
  private javax.swing.JLabel jLabel20;
  private javax.swing.JLabel jLabel21;
  private javax.swing.JLabel jLabel22;
  private javax.swing.JLabel jLabel23;
  private javax.swing.JLabel jLabel24;
  private javax.swing.JLabel jLabel25;
  private javax.swing.JLabel jLabel26;
  private javax.swing.JLabel jLabel27;
  private javax.swing.JLabel jLabel28;
  private javax.swing.JLabel jLabel29;
  private javax.swing.JLabel jLabel3;
  private javax.swing.JLabel jLabel30;
  private javax.swing.JLabel jLabel31;
  private javax.swing.JLabel jLabel32;
  private javax.swing.JLabel jLabel33;
  private javax.swing.JLabel jLabel34;
  private javax.swing.JLabel jLabel35;
  private javax.swing.JLabel jLabel36;
  private javax.swing.JLabel jLabel37;
  private javax.swing.JLabel jLabel39;
  private javax.swing.JLabel jLabel4;
  private javax.swing.JLabel jLabel41;
  private javax.swing.JLabel jLabel42;
  private javax.swing.JLabel jLabel43;
  private javax.swing.JLabel jLabel44;
  private javax.swing.JLabel jLabel45;
  private javax.swing.JLabel jLabel46;
  private javax.swing.JLabel jLabel47;
  private javax.swing.JLabel jLabel48;
  private javax.swing.JLabel jLabel49;
  private javax.swing.JLabel jLabel5;
  private javax.swing.JLabel jLabel50;
  private javax.swing.JLabel jLabel51;
  private javax.swing.JLabel jLabel52;
  private javax.swing.JLabel jLabel53;
  private javax.swing.JLabel jLabel54;
  private javax.swing.JLabel jLabel55;
  private javax.swing.JLabel jLabel56;
  private javax.swing.JLabel jLabel57;
  private javax.swing.JLabel jLabel58;
  private javax.swing.JLabel jLabel59;
  private javax.swing.JLabel jLabel6;
  private javax.swing.JLabel jLabel60;
  private javax.swing.JLabel jLabel61;
  private javax.swing.JLabel jLabel62;
  private javax.swing.JLabel jLabel63;
  private javax.swing.JLabel jLabel64;
  private javax.swing.JLabel jLabel65;
  private javax.swing.JLabel jLabel66;
  private javax.swing.JLabel jLabel67;
  private javax.swing.JLabel jLabel68;
  private javax.swing.JLabel jLabel7;
  private javax.swing.JLabel jLabel8;
  private javax.swing.JLabel jLabel9;
  private javax.swing.JPanel jPanel1;
  private javax.swing.JPanel jPanel10;
  private javax.swing.JPanel jPanel11;
  private javax.swing.JPanel jPanel13;
  private javax.swing.JPanel jPanel14;
  private javax.swing.JPanel jPanel15;
  private javax.swing.JPanel jPanel17;
  private javax.swing.JPanel jPanel18;
  private javax.swing.JPanel jPanel2;
  private javax.swing.JPanel jPanel21;
  private javax.swing.JPanel jPanel22;
  private javax.swing.JScrollPane jScrollPane1;
  private javax.swing.JScrollPane jScrollPane2;
  private javax.swing.JScrollPane jScrollPane3;
  private javax.swing.JScrollPane jScrollPane4;
  private javax.swing.JScrollPane jScrollPane5;
  private javax.swing.JTabbedPane jTabbedPane1;
  private javax.swing.JCheckBox keepAudioOpen;
  private javax.swing.JLabel keyStatus;
  private javax.swing.JPanel l1;
  private javax.swing.JTextField l1auth;
  private javax.swing.JCheckBox l1disableVideo;
  private javax.swing.JTextField l1host;
  private javax.swing.JComboBox l1key;
  private javax.swing.JTextField l1name;
  private javax.swing.JPasswordField l1pass;
  private javax.swing.JCheckBox l1secure;
  private javax.swing.JComboBox l1sip;
  private javax.swing.JCheckBox l1siplog;
  private javax.swing.JTextField l1user;
  private javax.swing.JPanel l2;
  private javax.swing.JTextField l2auth;
  private javax.swing.JCheckBox l2disableVideo;
  private javax.swing.JTextField l2host;
  private javax.swing.JComboBox l2key;
  private javax.swing.JTextField l2name;
  private javax.swing.JPasswordField l2pass;
  private javax.swing.JCheckBox l2same;
  private javax.swing.JComboBox l2sameidx;
  private javax.swing.JCheckBox l2secure;
  private javax.swing.JComboBox l2sip;
  private javax.swing.JCheckBox l2siplog;
  private javax.swing.JTextField l2user;
  private javax.swing.JPanel l3;
  private javax.swing.JTextField l3auth;
  private javax.swing.JCheckBox l3disableVideo;
  private javax.swing.JTextField l3host;
  private javax.swing.JComboBox l3key;
  private javax.swing.JTextField l3name;
  private javax.swing.JPasswordField l3pass;
  private javax.swing.JCheckBox l3same;
  private javax.swing.JComboBox l3sameidx;
  private javax.swing.JCheckBox l3secure;
  private javax.swing.JComboBox l3sip;
  private javax.swing.JCheckBox l3siplog;
  private javax.swing.JTextField l3user;
  private javax.swing.JPanel l4;
  private javax.swing.JTextField l4auth;
  private javax.swing.JCheckBox l4disableVideo;
  private javax.swing.JTextField l4host;
  private javax.swing.JComboBox l4key;
  private javax.swing.JTextField l4name;
  private javax.swing.JPasswordField l4pass;
  private javax.swing.JCheckBox l4same;
  private javax.swing.JComboBox l4sameidx;
  private javax.swing.JCheckBox l4secure;
  private javax.swing.JComboBox l4sip;
  private javax.swing.JCheckBox l4siplog;
  private javax.swing.JTextField l4user;
  private javax.swing.JPanel l5;
  private javax.swing.JTextField l5auth;
  private javax.swing.JCheckBox l5disableVideo;
  private javax.swing.JTextField l5host;
  private javax.swing.JComboBox l5key;
  private javax.swing.JTextField l5name;
  private javax.swing.JPasswordField l5pass;
  private javax.swing.JCheckBox l5same;
  private javax.swing.JComboBox l5sameidx;
  private javax.swing.JCheckBox l5secure;
  private javax.swing.JComboBox l5sip;
  private javax.swing.JCheckBox l5siplog;
  private javax.swing.JTextField l5user;
  private javax.swing.JPanel l6;
  private javax.swing.JTextField l6auth;
  private javax.swing.JCheckBox l6disableVideo;
  private javax.swing.JTextField l6host;
  private javax.swing.JComboBox l6key;
  private javax.swing.JTextField l6name;
  private javax.swing.JPasswordField l6pass;
  private javax.swing.JCheckBox l6same;
  private javax.swing.JComboBox l6sameidx;
  private javax.swing.JCheckBox l6secure;
  private javax.swing.JComboBox l6sip;
  private javax.swing.JCheckBox l6siplog;
  private javax.swing.JTextField l6user;
  private javax.swing.JButton move_audio_codec_down;
  private javax.swing.JButton move_audio_codec_up;
  private javax.swing.JButton move_video_codec_down;
  private javax.swing.JButton move_video_codec_up;
  private javax.swing.ButtonGroup natGroup;
  private javax.swing.JTextField natHost;
  private javax.swing.JRadioButton natIce;
  private javax.swing.JRadioButton natNone;
  private javax.swing.JPasswordField natPass;
  private javax.swing.JCheckBox natPrivate;
  private javax.swing.JRadioButton natStun;
  private javax.swing.JRadioButton natTurn;
  private javax.swing.JTextField natUser;
  private javax.swing.JComboBox outRingtone;
  private javax.swing.JCheckBox received;
  private javax.swing.JCheckBox reinvite;
  private javax.swing.JButton remove_audio_codec;
  private javax.swing.JButton remove_video_codec;
  private javax.swing.JCheckBox rport;
  private javax.swing.JCheckBox rtpRange;
  private javax.swing.JTextField rtpmax;
  private javax.swing.JTextField rtpmin;
  private javax.swing.JButton selectDownloadPath;
  private javax.swing.JButton selectInRingtone;
  private javax.swing.JButton selectOutRingtone;
  private javax.swing.JTextField sipExpires;
  private javax.swing.JCheckBox sipRange;
  private javax.swing.JTextField sipmax;
  private javax.swing.JTextField sipmin;
  private javax.swing.JCheckBox smallerFont;
  private javax.swing.ButtonGroup soundGroup;
  private javax.swing.JTextField speakerDelay;
  private javax.swing.JTextField speakerThreshold;
  private javax.swing.JTabbedPane tabs;
  private javax.swing.JPanel topology;
  private javax.swing.JRadioButton useNativeVideo;
  private javax.swing.JCheckBox usePublish;
  private javax.swing.JPanel video;
  private javax.swing.JComboBox videoDevice;
  private javax.swing.JSlider videoFPS;
  private javax.swing.ButtonGroup videoGroup;
  // End of variables declaration//GEN-END:variables

  private DefaultListModel disabledAudioCodecsList = new DefaultListModel();
  private DefaultListModel enabledAudioCodecsList = new DefaultListModel();
  private DefaultListModel disabledVideoCodecsList = new DefaultListModel();
  private DefaultListModel enabledVideoCodecsList = new DefaultListModel();

  /** Pops up the EditSettings dialog window and returns when the dialog is closed. */

  public static void editSettings(java.awt.Frame parent) {
    EditSettings dialog = new EditSettings(parent, true);
    dialog.setVisible(true);  //doesn't return until dialog is closed
  }

  private boolean validFieldNumber(String str, int min, int max) {
    if (!validField(str)) return false;
    for(int a=0;a<str.length();a++) if ((str.charAt(a) < '0') || (str.charAt(a) > '9')) return false;
    int value = JF.atoi(str);
    if ((value < min) || (value > max)) return false;
    return true;
  }

  private boolean validFieldHexNumber(String str) {
    if (!validField(str)) return false;
    if (str.length() != 6) return false;
    for(int a=0;a<str.length();a++) {
      if (
        ((str.charAt(a) < '0') || (str.charAt(a) > '9')) &&
        ((str.charAt(a) < 'A') || (str.charAt(a) > 'F')) &&
        ((str.charAt(a) < 'a') || (str.charAt(a) > 'f')) )
        return false;
    }
    return true;
  }

  private boolean validField(String str) {
    if (str.length() == 0) return false;
    if (str.indexOf('\"') != -1) return false;
    if (str.indexOf('\'') != -1) return false;
    return true;
  }
  public final static int MIN = 16;
  public final static int MAX = 256;

  private boolean validFields() {
    if (getAudioCodecs() == null) {
      JFAWT.showError("Error", "Must enable at least one audio codec");
      return false;
    }
    //check if port ranges are valid
    int smin = JF.atoi(sipmin.getText());
    int smax = JF.atoi(sipmax.getText());
    if (sipRange.isSelected()) {
      if ((smin <= 0) || (smax <= 0) || (smin > 65535) || (smax > 65535) || (smin > smax) || (smax-smin < 32)) {
        JFAWT.showError("Error", "SIP Port Range must include at least 32 ports");
        return false;
      }
      if (Settings.isLinux && smin < 1024) {
        JFAWT.showError("Error", "SIP Port Range must be > 1024 for Linux");
        return false;
      }
    }
    int rmin = JF.atoi(rtpmin.getText());
    int rmax = JF.atoi(rtpmax.getText());
    if (rtpRange.isSelected()) {
      if ((rmin <= 0) || (rmax <= 0) || (rmin > 65535) || (rmax > 65535) || (rmin > rmax) || (rmax-rmin < 128)) {
        JFAWT.showError("Error", "RTP Port Range must include at least 128 ports");
        return false;
      }
      if ((rmin & 0x1) == 0x1) {
        JFAWT.showError("Error", "RTP Port Range must start on an even port");
        return false;
      }
      if (Settings.isLinux && rmin < 1024) {
        JFAWT.showError("Error", "RTP Port Range must be > 1024 for Linux");
        return false;
      }
    }
    if (sipRange.isSelected() && rtpRange.isSelected()) {
      if (
        (smin >= rmin && smin <= rmax) ||
        (smax >= rmin && smax <= rmax) ||
        (smin <= rmin && smax >= rmax)
      ) {
        JFAWT.showError("Error", "SIP and RTP Port Ranges must not overlap");
        return false;
      }
    }
    int sipexpires = JF.atoi(sipExpires.getText());
    if (sipexpires < 60 || sipexpires > 3600) {
      JFAWT.showError("Error", "SIP Expires must be 60 to 3600 seconds.");
      return false;
    }
    return true;
  }

  private void loadSettings() {
    int idx;
    l1name.setText(Settings.current.lines[0].name);
    l1user.setText(Settings.current.lines[0].user);
    l1auth.setText(Settings.current.lines[0].auth);
    l1pass.setText(Settings.getPassword(Settings.current.lines[0].pass));
    l1host.setText(Settings.current.lines[0].host);
    l1disableVideo.setSelected(Settings.current.lines[0].disableVideo);
    l1secure.setSelected(Settings.current.lines[0].srtp);
    l1sip.setSelectedIndex(Settings.current.lines[0].transport);
    l1key.setSelectedIndex(Settings.current.lines[0].dtls ? 1 : 0);
    l1siplog.setSelected(Settings.current.lines[0].siplog);

    l2name.setText(Settings.current.lines[1].name);
    l2user.setText(Settings.current.lines[1].user);
    l2auth.setText(Settings.current.lines[1].auth);
    l2pass.setText(Settings.getPassword(Settings.current.lines[1].pass));
    l2host.setText(Settings.current.lines[1].host);
    l2same.setSelected(Settings.current.lines[1].same != -1);
    l2disableVideo.setSelected(Settings.current.lines[1].disableVideo);
    l2secure.setSelected(Settings.current.lines[1].srtp);
    l2sip.setSelectedIndex(Settings.current.lines[1].transport);
    l2key.setSelectedIndex(Settings.current.lines[1].dtls ? 1 : 0);
    l2siplog.setSelected(Settings.current.lines[1].siplog);
    idx = Settings.current.lines[1].same;
    if (idx != -1) l2sameidx.setSelectedIndex((idx > 0 ? idx-1 : idx)); else l2sameidx.setSelectedIndex(0);

    l3name.setText(Settings.current.lines[2].name);
    l3user.setText(Settings.current.lines[2].user);
    l3auth.setText(Settings.current.lines[2].auth);
    l3pass.setText(Settings.getPassword(Settings.current.lines[2].pass));
    l3host.setText(Settings.current.lines[2].host);
    l3same.setSelected(Settings.current.lines[2].same != -1);
    l3disableVideo.setSelected(Settings.current.lines[2].disableVideo);
    l3secure.setSelected(Settings.current.lines[2].srtp);
    l3sip.setSelectedIndex(Settings.current.lines[2].transport);
    l3key.setSelectedIndex(Settings.current.lines[2].dtls ? 1 : 0);
    l3siplog.setSelected(Settings.current.lines[2].siplog);
    idx = Settings.current.lines[2].same;
    if (idx != -1) l3sameidx.setSelectedIndex((idx > 1 ? idx-1 : idx)); else l3sameidx.setSelectedIndex(0);

    l4name.setText(Settings.current.lines[3].name);
    l4user.setText(Settings.current.lines[3].user);
    l4auth.setText(Settings.current.lines[3].auth);
    l4pass.setText(Settings.getPassword(Settings.current.lines[3].pass));
    l4host.setText(Settings.current.lines[3].host);
    l4same.setSelected(Settings.current.lines[3].same != -1);
    l4disableVideo.setSelected(Settings.current.lines[3].disableVideo);
    l4secure.setSelected(Settings.current.lines[3].srtp);
    l4sip.setSelectedIndex(Settings.current.lines[3].transport);
    l4key.setSelectedIndex(Settings.current.lines[3].dtls ? 1 : 0);
    l4siplog.setSelected(Settings.current.lines[3].siplog);
    idx = Settings.current.lines[3].same;
    if (idx != -1) l4sameidx.setSelectedIndex((idx > 2 ? idx-1 : idx)); else l4sameidx.setSelectedIndex(0);

    l5name.setText(Settings.current.lines[4].name);
    l5user.setText(Settings.current.lines[4].user);
    l5auth.setText(Settings.current.lines[4].auth);
    l5pass.setText(Settings.getPassword(Settings.current.lines[4].pass));
    l5host.setText(Settings.current.lines[4].host);
    l5same.setSelected(Settings.current.lines[4].same != -1);
    l5disableVideo.setSelected(Settings.current.lines[4].disableVideo);
    l5secure.setSelected(Settings.current.lines[4].srtp);
    l5sip.setSelectedIndex(Settings.current.lines[4].transport);
    l5key.setSelectedIndex(Settings.current.lines[4].dtls ? 1 : 0);
    l5siplog.setSelected(Settings.current.lines[4].siplog);
    idx = Settings.current.lines[4].same;
    if (idx != -1) l5sameidx.setSelectedIndex((idx > 3 ? idx-1 : idx)); else l5sameidx.setSelectedIndex(0);

    l6name.setText(Settings.current.lines[5].name);
    l6user.setText(Settings.current.lines[5].user);
    l6auth.setText(Settings.current.lines[5].auth);
    l6pass.setText(Settings.getPassword(Settings.current.lines[5].pass));
    l6host.setText(Settings.current.lines[5].host);
    l6same.setSelected(Settings.current.lines[5].same != -1);
    l6disableVideo.setSelected(Settings.current.lines[5].disableVideo);
    l6secure.setSelected(Settings.current.lines[5].srtp);
    l6sip.setSelectedIndex(Settings.current.lines[5].transport);
    l6key.setSelectedIndex(Settings.current.lines[5].dtls ? 1 : 0);
    l6siplog.setSelected(Settings.current.lines[5].siplog);
    idx = Settings.current.lines[5].same;
    if (idx != -1) l6sameidx.setSelectedIndex(idx); else l6sameidx.setSelectedIndex(0);

    downloadPath.setText(Settings.current.downloadPath);

    inRingtone.addItem("Standard Ring");
    inRingtone.addItem("North America Backtone");
    inRingtone.addItem("Europe Backtone");
    if (Settings.current.inRingtone.equals("*RING")) {
      inRingtone.setSelectedIndex(0);
    } else if (Settings.current.inRingtone.equals("*NA")) {
      inRingtone.setSelectedIndex(1);
    } else if (Settings.current.inRingtone.equals("*UK")) {
      inRingtone.setSelectedIndex(2);
    } else {
      inRingtone.addItem(Settings.current.inRingtone);
      inRingtone.setSelectedIndex(3);
    }

    outRingtone.addItem("Standard Ring");
    outRingtone.addItem("North America Backtone");
    outRingtone.addItem("Europe Backtone");
    if (Settings.current.outRingtone.equals("*RING")) {
      outRingtone.setSelectedIndex(0);
    } else if (Settings.current.outRingtone.equals("*NA")) {
      outRingtone.setSelectedIndex(1);
    } else if (Settings.current.outRingtone.equals("*UK")) {
      outRingtone.setSelectedIndex(2);
    } else {
      outRingtone.addItem(Settings.current.outRingtone);
      outRingtone.setSelectedIndex(3);
    }

    dndCodeOn.setText(Settings.current.dndCodeOn);
    dndCodeOff.setText(Settings.current.dndCodeOff);

    speakerThreshold.setText("" + Settings.current.speakerThreshold);
    speakerDelay.setText("" + Settings.current.speakerDelay);

    checkVersion.setSelected(Settings.current.checkVersion);
    disableLogging.setSelected(Settings.current.disableLogging);
    hideWhenMinimized.setSelected(Settings.current.hideWhenMinimized);
    exitWhenClosed.setSelected(Settings.current.exitWhenClosed);
    alwaysOnTop.setSelected(Settings.current.alwaysOnTop);
    keepAudioOpen.setSelected(Settings.current.keepAudioOpen);
    smallerFont.setSelected(Settings.current.smallerFont);
    usePublish.setSelected(Settings.current.usePublish);
    reinvite.setSelected(Settings.current.reinvite);
    autohold.setSelected(Settings.current.autohold);
//audio codecs
    if ((Settings.current.audioCodecs == null) || (Settings.current.audioCodecs.length() == 0)) {
      Settings.current.audioCodecs = "G729,PCMU";
    }
    disabledAudioCodecsList.clear();
    enabledAudioCodecsList.clear();
    String codecs[] = Settings.current.getAudioCodecs();
    for(int a=0;a<codecs.length;a++) {
      if (codecs[a].equals("PCMU")) enabledAudioCodecsList.addElement("g711u");
      if (codecs[a].equals("PCMA")) enabledAudioCodecsList.addElement("g711a");
      if (codecs[a].equals("GSM")) enabledAudioCodecsList.addElement("gsm");
      if (codecs[a].equals("G722")) enabledAudioCodecsList.addElement("g722");
      if (codecs[a].equals("G729")) enabledAudioCodecsList.addElement("g729a");
    }
    if (!Settings.current.hasAudioCodec(RTP.CODEC_G711u)) {
      disabledAudioCodecsList.addElement("g711u");
    }
    if (!Settings.current.hasAudioCodec(RTP.CODEC_G711a)) {
      disabledAudioCodecsList.addElement("g711a");
    }
    if (!Settings.current.hasAudioCodec(RTP.CODEC_GSM)) {
      disabledAudioCodecsList.addElement("gsm");
    }
    if (!Settings.current.hasAudioCodec(RTP.CODEC_G722)) {
      disabledAudioCodecsList.addElement("g722");
    }
    if (!Settings.current.hasAudioCodec(RTP.CODEC_G729a)) {
      disabledAudioCodecsList.addElement("g729a");
    }
//video codecs
    if ((Settings.current.videoCodecs == null) || (Settings.current.videoCodecs.length() == 0)) {
      Settings.current.videoCodecs = "VP8,H264,H263-1998,H263-2000,JPEG";
    }
    disabledVideoCodecsList.clear();
    enabledVideoCodecsList.clear();
    codecs = Settings.current.getVideoCodecs();
    for(int a=0;a<codecs.length;a++) {
      if (codecs[a].equals("JPEG")) enabledVideoCodecsList.addElement("JPEG");
      if (useH263) {
        if (codecs[a].equals("H263")) enabledVideoCodecsList.addElement("H.263");
      }
      if (codecs[a].equals("H263-1998")) enabledVideoCodecsList.addElement("H.263(1998)");
      if (codecs[a].equals("H263-2000")) enabledVideoCodecsList.addElement("H.263(2000)");
      if (codecs[a].equals("H264")) enabledVideoCodecsList.addElement("H.264");
      if (codecs[a].equals("VP8")) enabledVideoCodecsList.addElement("VP8");
    }
    if (!Settings.current.hasVideoCodec(RTP.CODEC_JPEG)) {
      disabledVideoCodecsList.addElement("JPEG");
    }
    if (useH263) {
      if (!Settings.current.hasVideoCodec(RTP.CODEC_H263)) {
        disabledVideoCodecsList.addElement("H.263");
      }
    }
    if (!Settings.current.hasVideoCodec(RTP.CODEC_H263_1998)) {
      disabledVideoCodecsList.addElement("H.263(1998)");
    }
    if (!Settings.current.hasVideoCodec(RTP.CODEC_H263_2000)) {
      disabledVideoCodecsList.addElement("H.263(2000)");
    }
    if (!Settings.current.hasVideoCodec(RTP.CODEC_H264)) {
      disabledVideoCodecsList.addElement("H.264");
    }
    if (!Settings.current.hasVideoCodec(RTP.CODEC_VP8)) {
      disabledVideoCodecsList.addElement("VP8");
    }

    disableVideo.setSelected(!Settings.current.nativeVideo);
    useNativeVideo.setSelected(Settings.current.nativeVideo);

    switch (Settings.current.nat) {
      case 0: natNone.setSelected(true); break;
      case 1: natNone.setSelected(true); break;
      case 2: natStun.setSelected(true); break;
      case 3: natTurn.setSelected(true); break;
      case 4: natIce.setSelected(true); break;
    }

    natPrivate.setSelected(Settings.current.natPrivate);

    natHost.setText(Settings.current.natHost);
    natUser.setText(Settings.current.natUser);
    natPass.setText(Settings.current.natPass);

    sipRange.setSelected(Settings.current.sipRange);
    sipmin.setText(Integer.toString(Settings.current.sipmin));
    sipmax.setText(Integer.toString(Settings.current.sipmax));

    rtpRange.setSelected(Settings.current.rtpRange);
    rtpmin.setText(Integer.toString(Settings.current.rtpmin));
    rtpmax.setText(Integer.toString(Settings.current.rtpmax));

    sipExpires.setText(Integer.toString(Settings.current.sipexpires));

    received.setSelected(Settings.current.received);
    rport.setSelected(Settings.current.rport);

    updateAudio();

    updateVideo();
  }

  private void saveSettings() {
    Settings.current.lines[0].name = l1name.getText();
    Settings.current.lines[0].user = l1user.getText();
    Settings.current.lines[0].auth = l1auth.getText();
    Settings.current.lines[0].pass = "crypto(1," + Settings.encodePassword(l1pass.getPassword()) + ")";
    Settings.current.lines[0].host = l1host.getText();
    Settings.current.lines[0].same = -1;
    Settings.current.lines[0].disableVideo = l1disableVideo.isSelected();
    Settings.current.lines[0].srtp = l1secure.isSelected();
    Settings.current.lines[0].transport = l1sip.getSelectedIndex();
    Settings.current.lines[0].dtls = l1key.getSelectedIndex() == 1;
    Settings.current.lines[0].siplog = l1siplog.isSelected();

    Settings.current.lines[1].name = l2name.getText();
    Settings.current.lines[1].user = l2user.getText();
    Settings.current.lines[1].auth = l2auth.getText();
    Settings.current.lines[1].pass = "crypto(1," + Settings.encodePassword(l2pass.getPassword()) + ")";
    Settings.current.lines[1].host = l2host.getText();
    Settings.current.lines[1].disableVideo = l2disableVideo.isSelected();
    Settings.current.lines[1].srtp = l2secure.isSelected();
    Settings.current.lines[1].transport = l2sip.getSelectedIndex();
    Settings.current.lines[1].dtls = l2key.getSelectedIndex() == 1;
    Settings.current.lines[1].siplog = l2siplog.isSelected();
    if (l2same.isSelected()) Settings.current.lines[1].same = l2sameidx.getSelectedIndex(); else Settings.current.lines[1].same = -1;
    if (Settings.current.lines[1].same > 0) Settings.current.lines[1].same++;

    Settings.current.lines[2].name = l3name.getText();
    Settings.current.lines[2].user = l3user.getText();
    Settings.current.lines[2].auth = l3auth.getText();
    Settings.current.lines[2].pass = "crypto(1," + Settings.encodePassword(l3pass.getPassword()) + ")";
    Settings.current.lines[2].host = l3host.getText();
    Settings.current.lines[2].disableVideo = l3disableVideo.isSelected();
    Settings.current.lines[2].srtp = l3secure.isSelected();
    Settings.current.lines[2].transport = l3sip.getSelectedIndex();
    Settings.current.lines[2].dtls = l3key.getSelectedIndex() == 1;
    Settings.current.lines[2].siplog = l3siplog.isSelected();
    if (l3same.isSelected()) Settings.current.lines[2].same = l3sameidx.getSelectedIndex(); else Settings.current.lines[2].same = -1;
    if (Settings.current.lines[2].same > 1) Settings.current.lines[2].same++;

    Settings.current.lines[3].name = l4name.getText();
    Settings.current.lines[3].user = l4user.getText();
    Settings.current.lines[3].auth = l4auth.getText();
    Settings.current.lines[3].pass = "crypto(1," + Settings.encodePassword(l4pass.getPassword()) + ")";
    Settings.current.lines[3].host = l4host.getText();
    Settings.current.lines[3].disableVideo = l4disableVideo.isSelected();
    Settings.current.lines[3].srtp = l4secure.isSelected();
    Settings.current.lines[3].transport = l4sip.getSelectedIndex();
    Settings.current.lines[3].dtls = l4key.getSelectedIndex() == 1;
    Settings.current.lines[3].siplog = l4siplog.isSelected();
    if (l4same.isSelected()) Settings.current.lines[3].same = l4sameidx.getSelectedIndex(); else Settings.current.lines[3].same = -1;
    if (Settings.current.lines[3].same > 2) Settings.current.lines[3].same++;

    Settings.current.lines[4].name = l5name.getText();
    Settings.current.lines[4].user = l5user.getText();
    Settings.current.lines[4].auth = l5auth.getText();
    Settings.current.lines[4].pass = "crypto(1," + Settings.encodePassword(l5pass.getPassword()) + ")";
    Settings.current.lines[4].host = l5host.getText();
    Settings.current.lines[4].disableVideo = l5disableVideo.isSelected();
    Settings.current.lines[4].srtp = l5secure.isSelected();
    Settings.current.lines[4].transport = l5sip.getSelectedIndex();
    Settings.current.lines[4].dtls = l5key.getSelectedIndex() == 1;
    Settings.current.lines[4].siplog = l5siplog.isSelected();
    if (l5same.isSelected()) Settings.current.lines[4].same = l5sameidx.getSelectedIndex(); else Settings.current.lines[4].same = -1;
    if (Settings.current.lines[4].same > 3) Settings.current.lines[4].same++;

    Settings.current.lines[5].name = l6name.getText();
    Settings.current.lines[5].user = l6user.getText();
    Settings.current.lines[5].auth = l6auth.getText();
    Settings.current.lines[5].pass = "crypto(1," + Settings.encodePassword(l6pass.getPassword()) + ")";
    Settings.current.lines[5].host = l6host.getText();
    Settings.current.lines[5].disableVideo = l6disableVideo.isSelected();
    Settings.current.lines[5].srtp = l6secure.isSelected();
    Settings.current.lines[5].transport = l6sip.getSelectedIndex();
    Settings.current.lines[5].dtls = l6key.getSelectedIndex() == 1;
    Settings.current.lines[5].siplog = l6siplog.isSelected();
    if (l6same.isSelected()) Settings.current.lines[5].same = l6sameidx.getSelectedIndex(); else Settings.current.lines[5].same = -1;

    Settings.current.downloadPath = downloadPath.getText();
    switch (inRingtone.getSelectedIndex()) {
      case 0: Settings.current.inRingtone = "*RING"; break;
      case 1: Settings.current.inRingtone = "*NA"; break;
      case 2: Settings.current.inRingtone = "*UK"; break;
      case 3: Settings.current.inRingtone = (String)inRingtone.getSelectedItem(); break;
    }
    switch (outRingtone.getSelectedIndex()) {
      case 0: Settings.current.outRingtone = "*RING"; break;
      case 1: Settings.current.outRingtone = "*NA"; break;
      case 2: Settings.current.outRingtone = "*UK"; break;
      case 3: Settings.current.outRingtone = (String)outRingtone.getSelectedItem(); break;
    }
    Settings.current.dndCodeOn = dndCodeOn.getText();
    Settings.current.dndCodeOff = dndCodeOff.getText();

    try {
      Settings.current.speakerThreshold = Integer.valueOf(speakerThreshold.getText());
    } catch (Exception e1) {
      Settings.current.speakerThreshold = 1000;
    }
    try {
      Settings.current.speakerDelay = Integer.valueOf(speakerDelay.getText());
    } catch (Exception e1) {
      Settings.current.speakerDelay = 1000;
    }

    Settings.current.checkVersion = checkVersion.isSelected();
    Settings.current.disableLogging = disableLogging.isSelected();
    Settings.current.hideWhenMinimized = hideWhenMinimized.isSelected();
    Settings.current.exitWhenClosed = exitWhenClosed.isSelected();
    Settings.current.alwaysOnTop = alwaysOnTop.isSelected();
    Settings.current.keepAudioOpen = keepAudioOpen.isSelected();
    Settings.current.smallerFont = smallerFont.isSelected();
    Settings.current.usePublish = usePublish.isSelected();
    Settings.current.reinvite = reinvite.isSelected();
    Settings.current.autohold = autohold.isSelected();
    Settings.current.audioCodecs = getAudioCodecs();
    Settings.current.videoCodecs = getVideoCodecs();

    if (disableVideo.isSelected()) Settings.current.nativeVideo = false;
    if (useNativeVideo.isSelected()) Settings.current.nativeVideo = true;

    Settings.current.audioInput = (String)audioInput.getSelectedItem();
    Settings.current.audioOutput = (String)audioOutput.getSelectedItem();

    Settings.current.videoDevice = (String)videoDevice.getSelectedItem();
//    Settings.current.videoResolution = (String)videoResolution.getSelectedItem();

    Settings.current.videoFPS = videoFPS.getValue();

    if (natNone.isSelected()) Settings.current.nat = 0;
    if (natStun.isSelected()) Settings.current.nat = 2;
    if (natTurn.isSelected()) Settings.current.nat = 3;
    if (natIce.isSelected()) Settings.current.nat = 4;

    Settings.current.natPrivate = natPrivate.isSelected();

    Settings.current.natHost = natHost.getText();
    Settings.current.natUser = natUser.getText();
    Settings.current.natPass = new String(natPass.getPassword());

    Settings.current.sipRange = sipRange.isSelected();
    Settings.current.sipmin = JF.atoi(sipmin.getText());
    Settings.current.sipmax = JF.atoi(sipmax.getText());

    Settings.current.rtpRange = rtpRange.isSelected();
    Settings.current.rtpmin = JF.atoi(rtpmin.getText());
    Settings.current.rtpmax = JF.atoi(rtpmax.getText());

    Settings.current.sipexpires = JF.atoi(sipExpires.getText());

    Settings.current.received = received.isSelected();
    Settings.current.rport = rport.isSelected();
  }

  private void selectDownloadPath() {
    JFileChooser chooser = new JFileChooser();
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setMultiSelectionEnabled(false);
    chooser.setCurrentDirectory(new File(downloadPath.getText()));
    if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) return;
    downloadPath.setText(chooser.getSelectedFile().toString().replaceAll("\\\\", "/"));
  }

  private void selectInRingtoneFilename() {
    JFileChooser chooser = new JFileChooser();
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setMultiSelectionEnabled(false);
    chooser.setCurrentDirectory(new File(JF.getUserPath()));
    chooser.setFileFilter(new FileNameExtensionFilter("WAV", "wav"));
    if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) return;
    String fn = chooser.getSelectedFile().toString().replaceAll("\\\\", "/");
    if (inRingtone.getItemCount() == 4) {
      inRingtone.removeItemAt(3);
    }
    inRingtone.addItem(fn);
    inRingtone.setSelectedIndex(3);
  }

  private void selectOutRingtoneFilename() {
    JFileChooser chooser = new JFileChooser();
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setMultiSelectionEnabled(false);
    chooser.setCurrentDirectory(new File(JF.getUserPath()));
    chooser.setFileFilter(new FileNameExtensionFilter("WAV", "wav"));
    if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) return;
    String fn = chooser.getSelectedFile().toString().replaceAll("\\\\", "/");
    if (outRingtone.getItemCount() == 4) {
      outRingtone.removeItemAt(3);
    }
    outRingtone.addItem(fn);
    outRingtone.setSelectedIndex(3);
  }

  private void setPosition() {
    Dimension d = getSize();
    Rectangle s = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
    setLocation(s.width/2 - d.width/2, s.height/2 - d.height/2);
  }

  private String getAudioCodecs() {
    int cnt = enabledAudioCodecsList.getSize();
    if (cnt == 0) return null;
    StringBuilder sb = new StringBuilder();
    for(int a=0;a<cnt;a++) {
      if (sb.length() > 0) sb.append(",");
      String codec = (String)enabledAudioCodecsList.get(a);
      if (codec.equals("g711u")) sb.append("PCMU");
      if (codec.equals("g711a")) sb.append("PCMA");
      if (codec.equals("gsm")) sb.append("GSM");
      if (codec.equals("g722")) sb.append("G722");
      if (codec.equals("g729a")) sb.append("G729");
    }
    return sb.toString();
  }
  private String getVideoCodecs() {
    int cnt = enabledVideoCodecsList.getSize();
    if (cnt == 0) return null;
    StringBuilder sb = new StringBuilder();
    for(int a=0;a<cnt;a++) {
      if (sb.length() > 0) sb.append(",");
      String codec = (String)enabledVideoCodecsList.get(a);
      if (codec.equals("JPEG")) sb.append("JPEG");
      if (useH263) {
        if (codec.equals("H.263")) sb.append("H263");
      }
      if (codec.equals("H.263(1998)")) sb.append("H263-1998");
      if (codec.equals("H.263(2000)")) sb.append("H263-2000");
      if (codec.equals("H.264")) sb.append("H264");
      if (codec.equals("VP8")) sb.append("VP8");
    }
    return sb.toString();
  }
  private void updateAudio() {
    AudioOutput output = new AudioOutput();
    String mixers[] = output.listDevices();

    if (Settings.current.audioOutput == null) Settings.current.audioOutput = "";

    audioOutput.setModel(new javax.swing.DefaultComboBoxModel(mixers));
    for(int a=0;a<mixers.length;a++) {
      if (Settings.current.audioOutput.equalsIgnoreCase(mixers[a])) {
        audioOutput.setSelectedIndex(a);
        break;
      }
    }

    AudioInput input = new AudioInput();
    mixers = input.listDevices();

    if (Settings.current.audioInput == null) Settings.current.audioInput = "";

    audioInput.setModel(new javax.swing.DefaultComboBoxModel(mixers));
    for(int a=0;a<mixers.length;a++) {
      if (Settings.current.audioInput.equalsIgnoreCase(mixers[a])) {
        audioInput.setSelectedIndex(a);
        break;
      }
    }
  }
  private void updateVideo() {
    String devices[];
    if (useNativeVideo.isSelected()) {
      Camera camera = new Camera();
      if (camera.init()) {
        devices = camera.listDevices();
        camera.uninit();
      } else {
        devices = new String[] { "<undefined>"};
      }
    } else {
      devices = new String[] { "<disabled>"};
    }

    if (Settings.current.videoDevice == null) Settings.current.videoDevice = "";

    videoDevice.setModel(new javax.swing.DefaultComboBoxModel(devices));
    for(int a=0;a<devices.length;a++) {
      if (Settings.current.videoDevice.equalsIgnoreCase(devices[a])) {
        videoDevice.setSelectedIndex(a);
        break;
      }
    }
    //TODO : probe available resModes from api
    String resModes[] = { "<default>", "160x120", "320x240", "640x480" };

/*    videoResolution.setModel(new javax.swing.DefaultComboBoxModel(resModes));
    for(int a=0;a<resModes.length;a++) {
      if (Settings.current.videoResolution.equalsIgnoreCase(resModes[a])) {
        videoResolution.setSelectedIndex(a);
        break;
      }
    }
*/

    videoFPS.setValue(Settings.current.videoFPS);
  }

  private void updateKeyStatus() {
    String fn = JF.getUserPath() + "/.jfphone.key";
    keyStatus.setText("???");
    if (!new File(fn).exists()) {
      keyStatus.setText("file not found");
      return;
    }
    KeyMgmt key = new KeyMgmt();
    try {
      key.open(new FileInputStream(fn), "password".toCharArray());
      if (key.getCRT("jfphone") == null) {
        keyStatus.setText("missing certificate");
        return;
      }
      if (key.getKEY("jfphone", "password".toCharArray()) == null) {
        keyStatus.setText("missing private key");
        return;
      }
      keyStatus.setText("valid");
    } catch (FileNotFoundException e) {
      keyStatus.setText("file not found");
    } catch (Exception e) {
      JFLog.log(e);
      keyStatus.setText("invalid");
    }
  }

  private void genKeys() {
    if (KeyMgmt.keytool(new String[] {
      "-genkey", "-debug", "-alias", "jfphone", "-keypass", "password", "-storepass", "password",
      "-keystore", JF.getUserPath() + "/.jfphone.key", "-validity", "3650", "-dname", dname.getText(),
      "-keyalg" , "RSA", "-keysize", "2048"
    })) {
      //"Generated self-signed SSL Certificate";
    } else {
      //"KeyTool Error";
    }
    updateKeyStatus();
  }
}
